简体   繁体   中英

Spring Data Jpa not support Groupby

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!

If you don't like @Query for some reason, you, at least, have 2 more options:

  1. CriteriaAPI with spring-data-jpa Specifications http://docs.spring.io/spring-data/jpa/docs/1.9.1.RELEASE/reference/html/#specifications
  2. QueryDSL http://www.querydsl.com/static/querydsl/4.0.7/reference/html_single/#d0e372

They both support grouping operations.

Yes CriteriaAPI supports groupBy but spring Specification not! class SimpleJpaRepository in getQuery replace query select/multiselect by query.select(root); :(

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM