-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Querydsl predicate using IN operator fails for DBRef [DATAMONGO-1810] #2716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Luis Miguel Ospina commented Digging a little bit into QueryDsl i found that when you use the: Predicate predicate = QObj1.Obj1.Obj2.id.eq("ID123"); The result query will be something like: { "obj2" : { "$ref" : "Obj2", "$id" : "ID123"} } But when you use the: Predicate predicate = QObj1.Obj1.Obj2.id.in(Arrays.asList("ID123","ID1234")); The result query will look like this: { "obj2" : { "$in" : ["ID123" , "ID1234"] } } the previous query doesn't work even if i use MongoDB directly. however it'll work if you change the query to this. { "obj2.$id" : { "$in" : ["ID123" , "ID1234"] } } |
Christoph Strobl commented Luis Miguel Ospina which version of Spring Data MongoDB are you using? I've tried to set up a testcase for the issue which passes just fine |
Luis Miguel Ospina commented
Can you post the test case here? |
Luis Miguel Ospina commented
Let me know if you need anything else |
Christoph Strobl commented thanks Luis Miguel Ospina! I see, seems Querydsl converts |
Christoph Strobl commented After a bit of investigation it seems likely that the issue cannot be solved entirely without requireing changes in Querydsl itself. I came accross Issue #2133 which currently prevents values used for This means, that we could make it work for id properties that do not require any additional conversion, such as Still without changes in Querydsl the following would still fail, as on User bart = new User();
bart.setUsername("[email protected]");
User lisa = new User();
lisa.setUsername("[email protected]");
operations.save(bart);
operations.save(lisa);
Person milhouse = new Person();
milhouse.setCoworker(bart);
operations.save(milhouse);
Person result = repoSupport.from(QPerson.person)
.where(QPerson.person.coworker.id.in(Arrays.asList(bart.getId(), lisa.getId())))
.fetchOne(); |
Luis Miguel Ospina commented Thank you so much Christoph, lets wait for an answer from the Querydsl team. |
Christoph Strobl commented Resolved via DATAMONGO-1848 |
Luis Miguel Ospina opened DATAMONGO-1810 and commented
Suppose i have these classes.
When i try to create a querydsl predicate all the Obj1 that matches the id of Obj2 it works fine if i search for only one Id (use the eq operation in the SimpleExpression queryDsl class), something like this.
Predicate predicate = QObj1.Obj1.Obj2.id.eq("ID123");
That will work perfect when i call the findAll(predicate) method.
But when ever i try to use the IN operator, looking for a bunch of Id's it will not work, something like this:
Predicate predicate = QObj1.Obj1.Obj2.id.in(Arrays.asList("ID123","ID1234"));
And try to call the findAll(predicate), that will not work at all, it returns no data, even if there's data that matches those ID's in the MongoDB.
Issue Links:
DATAMONGO-1848 Migrate to Document API-based Querydsl implementation
("depends on")
DATAMONGO-2010 SpringDataMongodbSerializer does not convert 'in' predicate for nested String id properties mapping to ObjectId
DATAMONGO-1394 References not handled correctly when using QueryDSL
The text was updated successfully, but these errors were encountered: