org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected AST node: NULL near line 1, column 59 [SELECT NEW support.hibernate.dto.EmployeeDTO(e.name, CAST(NULL as long), e.title) FROM support.hibernate.entity.Employee e WHERE e.name = :name]

Hibernate JIRA | Stephen Fikes | 7 months ago
  1. 0

    {code} ... org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected AST node: NULL near line 1, column 59 [SELECT NEW support.hibernate.dto.EmployeeDTO(e.name, CAST(NULL as long), e.title) FROM support.hibernate.entity.Employee e WHERE e.name = :name] 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.generate(QueryTranslatorImpl.java:240) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:205) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:138) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:104) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:79) at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:168) at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:222) at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:200) at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1703) at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:301) ... {code} Executing a query like the below {code} final String hql = "SELECT NEW support.hibernate.dto.EmployeeDTO(e.name, CAST(NULL as long), e.title) FROM Employee e WHERE e.name = :name"; {code} Looks like something changed between Hibernate 4.2.7.SP5-redhat-1 (EAP 6.2.4) and Hibernate 4.2.14.SP1-redhat-1 (EAP 6.3.0) with regard to antlr parsing so that the keyword 'NULL' causes a parse failure in the HQL query. The issue remains in 5.0.9 and 5.1.0 Replacing the 'CAST(NULL as long)' with 'CAST(12 as long)' works ... If the query in question is a {{@NamedQuery}} the failure will be at the point the entity manager is created. The same issue can be seen with a simple dynamic HQL query, however, as the testcase attached shows. The test uses an H2 db and can be run using 'mvn clean test'

    Hibernate JIRA | 7 months ago | Stephen Fikes
    org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected AST node: NULL near line 1, column 59 [SELECT NEW support.hibernate.dto.EmployeeDTO(e.name, CAST(NULL as long), e.title) FROM support.hibernate.entity.Employee e WHERE e.name = :name]
  2. 0

    {code} ... org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected AST node: NULL near line 1, column 59 [SELECT NEW support.hibernate.dto.EmployeeDTO(e.name, CAST(NULL as long), e.title) FROM support.hibernate.entity.Employee e WHERE e.name = :name] 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.generate(QueryTranslatorImpl.java:240) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:205) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:138) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:104) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:79) at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:168) at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:222) at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:200) at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1703) at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:301) ... {code} Executing a query like the below {code} final String hql = "SELECT NEW support.hibernate.dto.EmployeeDTO(e.name, CAST(NULL as long), e.title) FROM Employee e WHERE e.name = :name"; {code} Looks like something changed between Hibernate 4.2.7.SP5-redhat-1 (EAP 6.2.4) and Hibernate 4.2.14.SP1-redhat-1 (EAP 6.3.0) with regard to antlr parsing so that the keyword 'NULL' causes a parse failure in the HQL query. The issue remains in 5.0.9 and 5.1.0 Replacing the 'CAST(NULL as long)' with 'CAST(12 as long)' works ... If the query in question is a {{@NamedQuery}} the failure will be at the point the entity manager is created. The same issue can be seen with a simple dynamic HQL query, however, as the testcase attached shows. The test uses an H2 db and can be run using 'mvn clean test'

    Hibernate JIRA | 7 months ago | Stephen Fikes
    org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected AST node: NULL near line 1, column 59 [SELECT NEW support.hibernate.dto.EmployeeDTO(e.name, CAST(NULL as long), e.title) FROM support.hibernate.entity.Employee e WHERE e.name = :name]
  3. 0

    Exception raised when calling isEmpty/isNotEmpty on an @ElementCollection field

    GitHub | 3 years ago | julien-gonzalez
    java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected end of subtree [select myEntity from fr.openwide.business.model.MyEntity myEntity where myEntity.technologies is empty]
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    CAS 4.0 Service Management WebApp Setup Failing

    Stack Overflow | 2 years ago
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'servicesManager' defined in ServletContext resource [/WEB-INF/spring-configuration/applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.jasig.cas.services.DefaultServicesManagerImpl]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: AbstractRegisteredService is not mapped [select r from AbstractRegisteredService r]
  6. 0

    A table not mapped in hibernate

    Stack Overflow | 2 years ago
    org.hibernate.hql.internal.ast.QuerySyntaxException: Enseignants is not mapped [Select coount(p) from Enseignants p ]

  1. MoYapro 1 times, last 2 weeks ago
  2. MoYapro 1 times, last 2 months ago
  3. marcbouvierdav 1 times, last 2 months ago
  4. tfr 1 times, last 4 months ago
  5. davidvanlaatum 1 times, last 5 months ago
30 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 AST node: NULL near line 1, column 59 [SELECT NEW support.hibernate.dto.EmployeeDTO(e.name, CAST(NULL as long), e.title) FROM support.hibernate.entity.Employee e WHERE e.name = :name]

    at org.hibernate.hql.internal.ast.QuerySyntaxException.convert()
  2. Hibernate
    SessionImpl.createQuery
    1. org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:54)
    2. org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:47)
    3. org.hibernate.hql.internal.ast.ErrorCounter.throwQueryException(ErrorCounter.java:79)
    4. org.hibernate.hql.internal.ast.QueryTranslatorImpl.generate(QueryTranslatorImpl.java:240)
    5. org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:205)
    6. org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:138)
    7. org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:104)
    8. org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:79)
    9. org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:168)
    10. org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:222)
    11. org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:200)
    12. org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1703)
    12 frames
  3. Hibernate EJB
    AbstractEntityManagerImpl.createQuery
    1. org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:301)
    1 frame