I'm using Spring Data MongoDB and QueryDSL to perform some simple queries, but I'm having issues trying to use a predicate with a DBRef object's field.
It seems the DBRef are not resolved, so the query always returns empty results. There are some questions about this topic from 2014 mostly, and although there seem to have been some work done about it on both QueryDSL and Spring Data's side I still can't make it work and didn't find any working example.
I'm looking for a simple solution, as in the following simplified test case:
@Document
class Foo {
@Id Integer id;
@DBref Bar bar;
}
@Document
class Bar {
@Id Integer id;
String name;
}
interface FooRepository extends MongoRepository<Foo, Integer>, QueryDslPredicateExecutor<Foo> { ... }
and the query I'm trying to use :
fooRepository.findAll(QFoo.foo.bar.name.eq("test"))
I'm using QueryDSL 4.1.4, Spring Boot 1.5.3 with Spring Data MongoDB 1.10.3
Is this supported? Am I missing anything?