【问题标题】:What's wrong with this HQL? "No data type for node"这个 HQL 有什么问题? “节点没有数据类型”
【发布时间】:2010-11-03 23:41:29
【问题描述】:
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)
.setMaxResults(1)
.uniqueResult();

对我来说看起来不错,但结果是

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(SelectClause.java:145)
    at org.hibernate.hql.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:705)
    at org.hibernate.hql.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:529)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:645)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)

为什么?怎么了?

【问题讨论】:

    标签: java hibernate hql


    【解决方案1】:

    您尚未定义“gs”别名。你只有“ags”和“tgs”。

    【讨论】:

      猜你喜欢
      • 2015-03-18
      • 2014-12-15
      • 2014-07-18
      • 1970-01-01
      • 2018-07-20
      • 1970-01-01
      相关资源
      最近更新 更多