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.

  • I have a named query with an ENUM WHERE parameter defined as: @NamedQuery(name = StateArchive.UPDATE_OBJECTID, query = "UPDATE StateArchive a SET a.objectId = :objectId WHERE a.caseId = :caseId AND a.controlEvent = com.logitags.cibet.core.ControlEvent.DELETE") Creation of the EntityManagerFactory fails with following Exception: {color:red}2013-07-20 11:40:15,605 ERROR [ main] (ErrorCounter.java:reportError:50) - line 1:168: unexpected token: . line 1:168: unexpected token: . at org.hibernate.hql.internal.antlr.HqlBaseParser.primaryExpression(HqlBaseParser.java:876) at org.hibernate.hql.internal.antlr.HqlBaseParser.atom(HqlBaseParser.java:3472) at org.hibernate.hql.internal.antlr.HqlBaseParser.unaryExpression(HqlBaseParser.java:3250) at org.hibernate.hql.internal.antlr.HqlBaseParser.multiplyExpression(HqlBaseParser.java:3122) at org.hibernate.hql.internal.antlr.HqlBaseParser.additiveExpression(HqlBaseParser.java:2828) at org.hibernate.hql.internal.antlr.HqlBaseParser.concatenation(HqlBaseParser.java:568) at org.hibernate.hql.internal.antlr.HqlBaseParser.relationalExpression(HqlBaseParser.java:2595) at org.hibernate.hql.internal.antlr.HqlBaseParser.equalityExpression(HqlBaseParser.java:2551) at org.hibernate.hql.internal.antlr.HqlBaseParser.negatedExpression(HqlBaseParser.java:2420) at org.hibernate.hql.internal.antlr.HqlBaseParser.logicalAndExpression(HqlBaseParser.java:2346) at org.hibernate.hql.internal.antlr.HqlBaseParser.logicalOrExpression(HqlBaseParser.java:2301) at org.hibernate.hql.internal.antlr.HqlBaseParser.expression(HqlBaseParser.java:2011) at org.hibernate.hql.internal.antlr.HqlBaseParser.logicalExpression(HqlBaseParser.java:1787) at org.hibernate.hql.internal.antlr.HqlBaseParser.whereClause(HqlBaseParser.java:452) at org.hibernate.hql.internal.antlr.HqlBaseParser.updateStatement(HqlBaseParser.java:222) at org.hibernate.hql.internal.antlr.HqlBaseParser.statement(HqlBaseParser.java:140) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:266) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:180) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:105) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80) at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:168) at org.hibernate.internal.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:1071) at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:519) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1751) at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:920) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:59) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63){color} and {color:red}2013-07-20 11:40:15,637 ERROR [ main] (SessionFactoryImpl.java:<init>:524) - HHH000177: Error in named query: com.logitags.cibet.actuator.archive.StateArchive.UPDATE_OBJECTID org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: . near line 1, column 168 [UPDATE com.logitags.cibet.actuator.archive.StateArchive a SET a.objectId = :objectId WHERE a.caseId = :caseId AND a.controlEvent = com.logitags.cibet.core.ControlEvent.DELETE] 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.parse(QueryTranslatorImpl.java:276) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:180) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:105){color} However, when I use another ENUM value like com.logitags.cibet.core.ControlEvent.REDO the query passes. I suspect that the Hibernate query parser fails when an ENUM value is an SQL keyword. I tested also with UPDATE and INSERT, they also fail.
    via by Wolfgang Winter,
  • I have a named query with an ENUM WHERE parameter defined as: @NamedQuery(name = StateArchive.UPDATE_OBJECTID, query = "UPDATE StateArchive a SET a.objectId = :objectId WHERE a.caseId = :caseId AND a.controlEvent = com.logitags.cibet.core.ControlEvent.DELETE") Creation of the EntityManagerFactory fails with following Exception: {color:red}2013-07-20 11:40:15,605 ERROR [ main] (ErrorCounter.java:reportError:50) - line 1:168: unexpected token: . line 1:168: unexpected token: . at org.hibernate.hql.internal.antlr.HqlBaseParser.primaryExpression(HqlBaseParser.java:876) at org.hibernate.hql.internal.antlr.HqlBaseParser.atom(HqlBaseParser.java:3472) at org.hibernate.hql.internal.antlr.HqlBaseParser.unaryExpression(HqlBaseParser.java:3250) at org.hibernate.hql.internal.antlr.HqlBaseParser.multiplyExpression(HqlBaseParser.java:3122) at org.hibernate.hql.internal.antlr.HqlBaseParser.additiveExpression(HqlBaseParser.java:2828) at org.hibernate.hql.internal.antlr.HqlBaseParser.concatenation(HqlBaseParser.java:568) at org.hibernate.hql.internal.antlr.HqlBaseParser.relationalExpression(HqlBaseParser.java:2595) at org.hibernate.hql.internal.antlr.HqlBaseParser.equalityExpression(HqlBaseParser.java:2551) at org.hibernate.hql.internal.antlr.HqlBaseParser.negatedExpression(HqlBaseParser.java:2420) at org.hibernate.hql.internal.antlr.HqlBaseParser.logicalAndExpression(HqlBaseParser.java:2346) at org.hibernate.hql.internal.antlr.HqlBaseParser.logicalOrExpression(HqlBaseParser.java:2301) at org.hibernate.hql.internal.antlr.HqlBaseParser.expression(HqlBaseParser.java:2011) at org.hibernate.hql.internal.antlr.HqlBaseParser.logicalExpression(HqlBaseParser.java:1787) at org.hibernate.hql.internal.antlr.HqlBaseParser.whereClause(HqlBaseParser.java:452) at org.hibernate.hql.internal.antlr.HqlBaseParser.updateStatement(HqlBaseParser.java:222) at org.hibernate.hql.internal.antlr.HqlBaseParser.statement(HqlBaseParser.java:140) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:266) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:180) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:105) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80) at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:168) at org.hibernate.internal.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:1071) at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:519) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1751) at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:920) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:59) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63){color} and {color:red}2013-07-20 11:40:15,637 ERROR [ main] (SessionFactoryImpl.java:<init>:524) - HHH000177: Error in named query: com.logitags.cibet.actuator.archive.StateArchive.UPDATE_OBJECTID org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: . near line 1, column 168 [UPDATE com.logitags.cibet.actuator.archive.StateArchive a SET a.objectId = :objectId WHERE a.caseId = :caseId AND a.controlEvent = com.logitags.cibet.core.ControlEvent.DELETE] 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.parse(QueryTranslatorImpl.java:276) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:180) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:105){color} However, when I use another ENUM value like com.logitags.cibet.core.ControlEvent.REDO the query passes. I suspect that the Hibernate query parser fails when an ENUM value is an SQL keyword. I tested also with UPDATE and INSERT, they also fail.
    via by Wolfgang Winter,
  • Error executing query in QueryDSL
    via Stack Overflow by Genzotto
    ,
  • How to rewrite given query in jpql custom query?
    via Stack Overflow by iie
    ,
  • Hibernate one-to-one annotation exception
    via Stack Overflow by scotttty
    ,
  • Unexpected AST Node LEFT OUTER JOIN
    via Stack Overflow by wax_lyrical
    ,
    • org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: . near line 1, column 168 [UPDATE com.logitags.cibet.actuator.archive.StateArchive a SET a.objectId = :objectId WHERE a.caseId = :caseId AND a.controlEvent = com.logitags.cibet.core.ControlEvent.DELETE] 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.parse(QueryTranslatorImpl.java:276) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:180) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)

    Users with the same issue

    tvrmsmith
    10 times, last one,
    derprogger
    2 times, last one,
    nasimk
    33 times, last one,
    Pilleo
    138 times, last one,
    slash
    14 times, last one,
    28 more bugmates