Uploaded image for project: 'Hibernate ORM'
  1. HHH-7407

Second collection-valued IN expression throws QuerySyntaxExpression

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Out of Date
    • Affects Version/s: 4.0.1
    • Fix Version/s: None
    • Component/s: None
    • Environment:
      JBoss AS 7.1.1.Final, Hibernate 4.0.1.Final

      Description

      I have the following JPQL:

      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

      You can see that the second IN :docTypes0_, :docTypes1_, :docTypes2_, :docTypes3_ expression is missing the parentheses.

        Attachments

          Issue links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - Not Specified
                  Not Specified
                  Logged:
                  Time Spent - 13m
                  13m