|
I have a class:
public class Project { private Long id; private boolean enabled = true; private Date expiry = new Date(); ... }
If I run a Criteria query with the following order clause:
cq.orderBy( cb.desc( cb.and( cb.isTrue( root.get( Project_.enabled ) ), cb.lessThan( cb.currentDate(), root.get( Project_.expiry ) ) ) ) );
I get the following error: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected AST node: and near line 1, column 105 [select generatedAlias0 from test.Project as generatedAlias0 order by ( generatedAlias0.enabled = true ) and ( current_date()<generatedAlias0.expiry ) desc]
However, running the SQL directly on the database works well. It seems the AST verifications are a bite too tight.
The test case is attached.
|