org.hibernate.hql.internal.ast.QuerySyntaxException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • 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}
    via by Etienne Miret,
  • 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}
    via by Etienne Miret,
  • 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.
    via by Etienne Miret,
  • 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.
    via by Etienne Miret,
  • Spring boot + Hibernate - User is not mapped
    via by Unknown author,
  • Class not mapped exception (but it is mapped)?
    via Stack Overflow by Dave
    ,
    • 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)

    Users with the same issue

    derprogger
    2 times, last one,
    nasimk
    33 times, last one,
    slash
    14 times, last one,
    tomthomas
    2 times, last one,
    Unknown visitor1 times, last one,
    38 more bugmates