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

HQL "x member of treat(y as Type).collections" fails to parse

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.3.6, 5.0.1
    • Fix Version/s: 5.0.7
    • Component/s: query-hql

      Description

      Parsing the following query throws a QuerySyntaxException:

      TreatTest.java
      public class TreatTest extends BaseCoreFunctionalTestCase {
      
          @Override
          public String[] getMappings() {
              return new String[] { "hql/Animal.hbm.xml" };
          }
      
          @Test
          public void memberOfTreatTest() {
              final Session s = openSession();
      
              s.createQuery( "select pet"
                      + " from Animal pet, Animal owner"
                      + " where pet member of treat (owner as Human).pets"
              );
      
              s.close();
          }
      
      }
      

      Exception thrown:

      org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: ( near line 1, column 114 [select pet from org.hibernate.test.hql.Animal pet, org.hibernate.test.hql.Animal owner where pet member of treat (owner as Human).pets]
      	at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:91)
      	at org.hibernate.hql.internal.ast.ErrorCounter.throwQueryException(ErrorCounter.java:109)
      	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:304)
      	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:203)
      	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:158)
      	at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:126)
      	at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:88)
      	at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:167)
      	at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:301)
      	at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:239)
      	at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1800)
      	at org.hibernate.test.hql.TreatTest.memberOfTreatTest(TreatTest.java:46)
      

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 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 - 2h
                2h