java.lang.IllegalStateException: No data type for node: org.hibernate.hql.internal.ast.tree.AggregateNode \-[AGGREGATE] AggregateNode: 'MAX'

Hibernate JIRA | Moritz Becker | 2 years ago
  1. 0

    When trying to apply an aggregate function on a subquery an error occurs during query compilation for all aggregate functions. I tested this with the following query (for other aggregate functions by replacing AVG): SELECT d.id, AVG((SELECT COUNT(localized) FROM Person p LEFT JOIN p.localized localized WHERE p.id = c.id)) AS localizedCount FROM Document d LEFT JOIN d.contacts c GROUP BY d.id Also, COUNT(subquery) seems not to be supported by the HQL grammar. The corresponding stack traces are: - for AVG Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected AST node: query [SELECT d.id, AVG((SELECT COUNT(localized) FROM hibernate.bug.model.Person p LEFT JOIN p.localized localized WHERE p.id = c.id)) AS localizedCount FROM hibernate.bug.model.Document d LEFT JOIN d.contacts c GROUP BY d.id] 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.analyze(QueryTranslatorImpl.java:257) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:138) 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.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:291) - for MAX (and likewise for MIN) java.lang.IllegalStateException: No data type for node: org.hibernate.hql.internal.ast.tree.AggregateNode \-[AGGREGATE] AggregateNode: 'MAX' at org.hibernate.hql.internal.ast.tree.SelectClause.initializeExplicitSelectClause(SelectClause.java:153) at org.hibernate.hql.internal.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:860) at org.hibernate.hql.internal.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:650) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:663) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:299) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:247) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:250) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:138) 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.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:291) - for SUM java.lang.NullPointerException at org.hibernate.dialect.function.StandardAnsiSqlAggregationFunctions$SumFunction.determineJdbcTypeCode(StandardAnsiSqlAggregationFunctions.java:145) at org.hibernate.dialect.function.StandardAnsiSqlAggregationFunctions$SumFunction.getReturnType(StandardAnsiSqlAggregationFunctions.java:157) at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.findFunctionReturnType(SessionFactoryHelper.java:406) at org.hibernate.hql.internal.ast.tree.AggregateNode.getDataType(AggregateNode.java:83) at org.hibernate.hql.internal.ast.tree.SelectClause.initializeExplicitSelectClause(SelectClause.java:151) at org.hibernate.hql.internal.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:860) at org.hibernate.hql.internal.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:650) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:663) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:299) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:247) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:250) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:138) 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.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:291)

    Hibernate JIRA | 2 years ago | Moritz Becker
    java.lang.IllegalStateException: No data type for node: org.hibernate.hql.internal.ast.tree.AggregateNode \-[AGGREGATE] AggregateNode: 'MAX'
  2. 0

    When trying to apply an aggregate function on a subquery an error occurs during query compilation for all aggregate functions. I tested this with the following query (for other aggregate functions by replacing AVG): SELECT d.id, AVG((SELECT COUNT(localized) FROM Person p LEFT JOIN p.localized localized WHERE p.id = c.id)) AS localizedCount FROM Document d LEFT JOIN d.contacts c GROUP BY d.id Also, COUNT(subquery) seems not to be supported by the HQL grammar. The corresponding stack traces are: - for AVG Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected AST node: query [SELECT d.id, AVG((SELECT COUNT(localized) FROM hibernate.bug.model.Person p LEFT JOIN p.localized localized WHERE p.id = c.id)) AS localizedCount FROM hibernate.bug.model.Document d LEFT JOIN d.contacts c GROUP BY d.id] 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.analyze(QueryTranslatorImpl.java:257) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:138) 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.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:291) - for MAX (and likewise for MIN) java.lang.IllegalStateException: No data type for node: org.hibernate.hql.internal.ast.tree.AggregateNode \-[AGGREGATE] AggregateNode: 'MAX' at org.hibernate.hql.internal.ast.tree.SelectClause.initializeExplicitSelectClause(SelectClause.java:153) at org.hibernate.hql.internal.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:860) at org.hibernate.hql.internal.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:650) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:663) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:299) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:247) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:250) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:138) 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.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:291) - for SUM java.lang.NullPointerException at org.hibernate.dialect.function.StandardAnsiSqlAggregationFunctions$SumFunction.determineJdbcTypeCode(StandardAnsiSqlAggregationFunctions.java:145) at org.hibernate.dialect.function.StandardAnsiSqlAggregationFunctions$SumFunction.getReturnType(StandardAnsiSqlAggregationFunctions.java:157) at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.findFunctionReturnType(SessionFactoryHelper.java:406) at org.hibernate.hql.internal.ast.tree.AggregateNode.getDataType(AggregateNode.java:83) at org.hibernate.hql.internal.ast.tree.SelectClause.initializeExplicitSelectClause(SelectClause.java:151) at org.hibernate.hql.internal.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:860) at org.hibernate.hql.internal.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:650) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:663) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:299) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:247) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:250) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:138) 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.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:291)

    Hibernate JIRA | 2 years ago | Moritz Becker
    java.lang.IllegalStateException: No data type for node: org.hibernate.hql.internal.ast.tree.AggregateNode \-[AGGREGATE] AggregateNode: 'MAX'
  3. 0

    SOLVED: Hibernate ERROR: unexpected end of subtree when calling custom functions

    Stack Overflow | 2 years ago | Fazia
    java.lang.IllegalStateException: No data type for node: org.hibernate.hql.internal.ast.tree.MethodNode \-[METHOD_CALL] MethodNode: '(' +-[METHOD_NAME] IdentNode: 'gen_dairyno' {originalText=gen_dairyno} \-[EXPR_LIST] SqlNode: 'exprList'
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    JPQL query - inner join no data type for node

    Stack Overflow | 2 years ago | user2987444
    java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.tvfreakz.repository.ChannelProgrammeRepository.findScheduledPerformerProgrammes(java.lang.Long,java.util.Date,java.util.Date)!
  6. 0

    Hibernate HQL Join Query DOT node with no left-hand-side

    Stack Overflow | 2 years ago | iCode
    java.lang.IllegalStateException: DOT node with no left-hand-side!

  1. marcbouvierdav 3 times, last 4 months ago
7 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. java.lang.IllegalStateException

    No data type for node: org.hibernate.hql.internal.ast.tree.AggregateNode \-[AGGREGATE] AggregateNode: 'MAX'

    at org.hibernate.hql.internal.ast.tree.SelectClause.initializeExplicitSelectClause()
  2. Hibernate
    SessionImpl.createQuery
    1. org.hibernate.hql.internal.ast.tree.SelectClause.initializeExplicitSelectClause(SelectClause.java:153)
    2. org.hibernate.hql.internal.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:860)
    3. org.hibernate.hql.internal.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:650)
    4. org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:663)
    5. org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:299)
    6. org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:247)
    7. org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:250)
    8. org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185)
    9. org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:138)
    10. org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:105)
    11. org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
    12. org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:168)
    13. org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:222)
    14. org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:200)
    15. org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1703)
    15 frames
  3. Hibernate EJB
    AbstractEntityManagerImpl.createQuery
    1. org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:291)
    1 frame