SELECT ed
FROM ExternalDocument ed
LEFT JOIN FETCH ed.documentType dt
JOIN FETCH ed.company co
WHERE co IN :companies AND (dt IS NULL OR dt IN :docTypes)
ORDER BY ed.fileName
Since AND binds tighter than OR the parentheses are mandatory. (:companies and :docTypes are both java.util.List)
However, Hibernate fails with:
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected AST node: {vector} [SELECT ed FROM de.company.project.model.ExternalDocument ed LEFT JOIN FETCH ed.documentType dt JOIN FETCH ed.company co WHERE co IN (:companies0_, :companies1_, :companies2_) AND (dt IS NULL OR dt IN :docTypes0_, :docTypes1_, :docTypes2_, :docTypes3_) ORDER BY ed.fileName]
at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:54)
at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:47)
at org.hibernate.hql.internal.ast.ErrorCounter.throwQueryException(ErrorCounter.java:79)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:255)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:183)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:119)
at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:214)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1107)
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:252)
... 154 more
I'm using Hibernate 4.0.1.Final, the version that comes with JBoss AS 7.1.1.Final.
I have the following JPQL:
Since AND binds tighter than OR the parentheses are mandatory. (:companies and :docTypes are both java.util.List)
However, Hibernate fails with:
I'm using Hibernate 4.0.1.Final, the version that comes with JBoss AS 7.1.1.Final.
Is this a recurring bug?