Is it possible to specify Join Fetch when using QueryDsl and Spring Data Repository?
-
Here is the spring documentation explaining what to do: docs.spring.io/spring-data/jpa/docs/current/reference/html/…Ted Gulesserian– Ted Gulesserian2017-10-07 17:51:26 +00:00Commented Oct 7, 2017 at 17:51
-
Yes, thanks, but I wanted to find the way how to do it without annotations.Max– Max2017-10-09 08:35:32 +00:00Commented Oct 9, 2017 at 8:35
Add a comment
|
1 Answer
No, there's no keyword in Spring Data JPA to trigger a fetch. But you can write a Custom Repository and implement a query using Querydsl there.
2 Comments
Max
It's possible to use Query annotation, and specify fetch join there. But when I implement QueryDslPredicateExecutor to my repository, I can't mix it with Query annotation.
Simon
Yes, that's right. The
QueryDslPredicateExecutor can be used to perform queries only using Querydsl Predicates (where you can't use fetch()). For instance: Predicate isOld = person.age.gt(65); repository.findAll(isOld);