I have to write a query, which expresses something like this:
Code:
SELECT f.a, COUNT(f.a), SUM(f.c), f.x IS NOT NULL
FROM Foo AS f
GROUP BY f.a, f.x IS NOT NULL" +
ORDER BY f.a, f.x IS NOT NULL DESC
The problem is is not null is not supported in the group by clause - I get "org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: is not null". The JPA documentation states that
Code:
groupby_clause ::= GROUP BY groupby_item {, groupby_item}*
groupby_item ::= single_valued_path_expression | identification_variable
and neither single_valued_path_expression nor identification_variable can contain the IS NOT NULL operator.
Is there any other possibility to express this in JPQL?