问题
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