Spring Data Jpa not support Groupby
17,921
Solution 1
If you don't like @Query for some reason, you, at least, have 2 more options:
- CriteriaAPI with spring-data-jpa Specifications http://docs.spring.io/spring-data/jpa/docs/1.9.1.RELEASE/reference/html/#specifications
- QueryDSL http://www.querydsl.com/static/querydsl/4.0.7/reference/html_single/#d0e372
They both support grouping operations.
Solution 2
Yes CriteriaAPI supports groupBy but spring Specification not! class SimpleJpaRepository in getQuery replace query select/multiselect by query.select(root); :(
Related videos on Youtube
Author by
topcan5
Updated on September 15, 2022Comments
-
topcan5 over 1 year
I need a quick search for a list of objects. Is that true that Spring Data Jpa doesn't support GroupBy? If so, what's the work around without writing
@Query
?Thanks!
-
Kateract over 7 yearsWelcome to StackOverflow! Please see How to Answer for tips on giving good answer to questions on this site. In general, it's best to focus on new questions that don't have accepted answers. Also, check out the formatting options to correctly show
code blocks
.