Java – What’s wrong with this HQL? “No data type for node”


session.createQuery("Select attribute from GoodsSection tgs " +
    "join gs.ascendants ags join ags.attributes attribute " +
    "where attribute.outerId = :outerId and tgs = :section ")
.setString("outerId", pOuterId)
.setEntity("section", section)

Looks fine to me, but the result is

java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.tree.IdentNode 
 \-[IDENT] IdentNode: 'attribute' {originalText=attribute}

    at org.hibernate.hql.ast.tree.SelectClause.initializeExplicitSelectClause(
    at org.hibernate.hql.ast.HqlSqlWalker.useSelectClause(
    at org.hibernate.hql.ast.HqlSqlWalker.processQuery(
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(

Why? What's wrong?

Best Solution

You haven't defined the "gs" alias. You only have "ags" and "tgs".

Related Question