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]

Hibernate JIRA | Etienne Miret | 3 years ago
tip
Do you find the tips below useful? Click on the to mark them and say thanks to rafael . Or join the community to write better ones.
  1. 0

    Parsing the following query throws a QuerySyntaxException: {code:title=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(); } } {code} Exception thrown: {code} 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) {code}

    Hibernate JIRA | 3 years ago | Etienne Miret
    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]
  2. 0

    Parsing the following query throws a QuerySyntaxException: {code:title=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(); } } {code} Exception thrown: {code} 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) {code}

    Hibernate JIRA | 3 years ago | Etienne Miret
    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]
  3. 0
    samebug tip
    Your code probably has some syntax issue with how you're making the query request, more on this here: goo.gl/9wtLyd If your problem wasn't solved by that link, check this one as well: https://goo.gl/zBTzbl
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Section 4.4.4.1 of the JPA 2.1 specification (which gives the syntax for path expressions) explicitly allows nested "treat as" statements, yet they are not currently supported by Hibernate. The following test case throws a QuerySyntaxExpression: {code:title=TreatTest.java} public class TreatTest extends BaseCoreFunctionalTestCase { @Override public String[] getMappings() { return new String[] { "hql/Animal.hbm.xml" }; } @Test public void nestedTreatTest() { final Session s = openSession(); s.createQuery( "from Animal h where treat ( treat ( h as Human ).father as Human ).pets is empty" ); } } {code} The stacktrace of the thrown expression is: {code} org.hibernate.hql.internal.ast.QuerySyntaxException: expecting "as", found '(' near line 1, column 58 [from org.hibernate.test.hql.Animal h where treat ( treat ( h as Human ).father as Human ).pets is empty] 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.whereTreatTest(TreatTest.java:95) {code} My pull request for HHH-9342 added support for nested "treat as" just after a "member of" construction, but it is currently the only place where nested treat as are supported. This new bug report is in order to support them everywhere where they should be allowed.

    Hibernate JIRA | 3 years ago | Etienne Miret
    org.hibernate.hql.internal.ast.QuerySyntaxException: expecting "as", found '(' near line 1, column 58 [from org.hibernate.test.hql.Animal h where treat ( treat ( h as Human ).father as Human ).pets is empty]
  6. 0

    Section 4.4.4.1 of the JPA 2.1 specification (which gives the syntax for path expressions) explicitly allows nested "treat as" statements, yet they are not currently supported by Hibernate. The following test case throws a QuerySyntaxExpression: {code:title=TreatTest.java} public class TreatTest extends BaseCoreFunctionalTestCase { @Override public String[] getMappings() { return new String[] { "hql/Animal.hbm.xml" }; } @Test public void nestedTreatTest() { final Session s = openSession(); s.createQuery( "from Animal h where treat ( treat ( h as Human ).father as Human ).pets is empty" ); } } {code} The stacktrace of the thrown expression is: {code} org.hibernate.hql.internal.ast.QuerySyntaxException: expecting "as", found '(' near line 1, column 58 [from org.hibernate.test.hql.Animal h where treat ( treat ( h as Human ).father as Human ).pets is empty] 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.whereTreatTest(TreatTest.java:95) {code} My pull request for HHH-9342 added support for nested "treat as" just after a "member of" construction, but it is currently the only place where nested treat as are supported. This new bug report is in order to support them everywhere where they should be allowed.

    Hibernate JIRA | 3 years ago | Etienne Miret
    org.hibernate.hql.internal.ast.QuerySyntaxException: expecting "as", found '(' near line 1, column 58 [from org.hibernate.test.hql.Animal h where treat ( treat ( h as Human ).father as Human ).pets is empty]

  1. tomthomas 50 times, last 6 days ago
  2. richard77 1 times, last 3 months ago
  3. MoYapro 2 times, last 3 months ago
  4. marcbouvierdav 1 times, last 5 months ago
  5. tfr 1 times, last 8 months ago
1 more registered users
31 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. 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()
  2. Hibernate
    SessionImpl.createQuery
    1. org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:91)
    2. org.hibernate.hql.internal.ast.ErrorCounter.throwQueryException(ErrorCounter.java:109)
    3. org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:304)
    4. org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:203)
    5. org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:158)
    6. org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:126)
    7. org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:88)
    8. org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:167)
    9. org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:301)
    10. org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:239)
    11. org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1800)
    11 frames
  3. org.hibernate.test
    TreatTest.memberOfTreatTest
    1. org.hibernate.test.hql.TreatTest.memberOfTreatTest(TreatTest.java:46)
    1 frame