Skip to content

$looup does NOT work with @DBRef. #4123

Closed
@ArayChou

Description

@ArayChou

I write a demo project to demostrate it. https://github.com/ArayChou/DBRefLookupTest . Please run unit test test.QueryTest to produce this issue.

@Document("person") public class PersonPo { @Id private String id; private String name; @DBRef private PersonPo mother; @DocumentReference private PersonPo father; }

AggregationOperation motherLookupDoesNotWork = Aggregation.lookup( "person", "mother.$id", "_id", "mother" );

The above $lookup operation does NOT work. it should work.

And I found a temporary solution, adding a (virtual) field to the document as following, it works.
AddFieldsOperation addMotherId = Aggregation.addFields().addField("motherId") .withValue("$mother.$id") .build(); AggregationOperation motherLookupWorks = Aggregation.lookup( "person", "motherId", "_id", "mother" );

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions