In repository interface which extends JpaRepository, if we have our custom query e.g "getAllCustomersWhoAreOlderThan", how can we pass custom specification to this method?
Asked
Active
Viewed 2,192 times
1
-
Possible duplicate of [Can I combine a @Query definition and Specifications on one Spring Data JPA repository method?](https://stackoverflow.com/questions/26379522/can-i-combine-a-query-definition-and-specifications-on-one-spring-data-jpa-repo) – ValerioMC Mar 21 '19 at 11:31
-
I didn't get any resolution from this thread. So I asked the question – AJ Winchester Mar 22 '19 at 12:48
1 Answers
0
you can't pass Specifications in mix @Query (or query-methods). the following queries using Specifications:
- count(Specification spec)
- List findAll(Specification spec)
- Page findAll(Specification spec, Pageable pageable)
- List findAll(Specification spec, Sort sort)
- T findOne(Specification spec)

zohreh
- 913
- 1
- 7
- 9
-
1These are the methods provided in repository. Can we use specifications in custom queries just like we use pageable or sort? – AJ Winchester Jul 14 '19 at 10:17
-
-
That's just an example. Can we use SPECIFICATIONS, LIKE we use paging and sorting – AJ Winchester Jul 15 '19 at 15:10
-