Spring Data JPA JPQL queries on parent interface

无人久伴 提交于 2019-12-06 06:19:28

Will it work if you will split query into 3 parts: start, entity and end of query? Than, if it'll work, in each interface you define constant like

String ENTITY = "ActivityRating";

And then you can use it like

@Query(RatingRepository.QUERY_START + ENTITY + RatingRepository.QUERY_END)
List<RatingCountVo> getRatingCounts();

BTW, there is no need to define public modifier in interface.

UPDATE: here is described another way:

@Query("SELECT NEW com.foo.RatingCountVo(e.rating, COUNT(e.rating)) FROM #{#entityName} e GROUP BY e.rating
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!