JPA count distinct multiple expressions

十年热恋 提交于 2019-12-12 03:44:23

问题


CriteriaBuilder.countDistinct(Expression e)

It takes one expression only. How to count distinct multiple expressions? For example,

Country              Language
-------------------------------

In JPA CriteriaQuery, how to count different pairs of (country, language)?

Thanks,


回答1:


You cannot do that with JPQL. JPQL BNF is very clear

aggregate_expression ::= { AVG | MAX | MIN | SUM } ([DISTINCT] state_field_path_expression) |
    COUNT ([DISTINCT] identification_variable | state_field_path_expression |
    single_valued_object_path_expression)


来源:https://stackoverflow.com/questions/37781683/jpa-count-distinct-multiple-expressions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!