I have a class: {code:title=Project.class.java|borderStyle=solid} public class Project { private Long id; private boolean enabled = true; private Date expiry = new Date(); ... } {code}
If I run a Criteria query with the following order clause:
{code:title=ProjectDAO.java|borderStyle=solid} ... cq.orderBy( cb.desc( cb.and( cb.isTrue( root.get( Project_.enabled ) ), cb.lessThan( cb.currentDate(), root.get( Project_.expiry ) ) ) ) ); ... {code} 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.
|