【问题标题】:HTTP Status 500 - No data type for node: org.hibernate.hql.internal.ast.tree.IdentNodeHTTP 状态 500 - 节点没有数据类型:org.hibernate.hql.internal.ast.tree.IdentNode
【发布时间】:2016-08-11 05:36:37
【问题描述】:

我知道这个问题已经被问过很多次了。我已经搜索了整个 Stack Overflow,但无法从中得到太多。我知道当查询中使用的列名与 bean 类中指定的属性不同时会出现此异常,但是,我的两个参数都是相同的。

完全错误:

java.lang.IllegalStateException:节点没有数据类型:org.hibernate.hql.internal.ast.tree.IdentNode +-[IDENT] IdentNode: 'iduserInfo' {originalText=iduserInfo}

这是我的查询:

List<Object[]>  tuples = session.createQuery( "select iduserInfo, SUM(points) from " + persistentClass.getName() 
            + " GROUP BY iduserInfo "
            + "ORDER BY SUM(points) DESC").list();

这是我的 bean 类:

@XmlRootElement
@Entity
@Table(name = "userInfo")
public class UserInfo {

protected @XmlElement int id;
protected @XmlElement int iduserInfo;
protected @XmlElement int idquestion;
protected @XmlElement String location;
protected @XmlElement String state;
protected @XmlElement String type;
protected @XmlElement Date timestamp;
protected @XmlElement Double latitude;
protected @XmlElement Double longitude;
protected @XmlElement Integer points;  

查询针对除 iduserInfo 和 idquestions 之外的所有参数运行。我在表中的列名具有完全相同的参数,虽然我在某处读到它并不重要,您只需要将参数与 bean 类匹配即可!

【问题讨论】:

  • 究竟是什么问题?

标签: java hibernate rest hql


【解决方案1】:

我通过将列名“iduserInfo”和“idquestion”分别更改为“user”和“question”解决了这个问题。我认为这样做的原因是已经有一个带有“id”的参数。我不明白为什么这会导致问题,但是将列名更改为与参数“id”无关的东西对我来说是诀窍!

【讨论】:

    猜你喜欢
    • 2014-12-15
    • 2019-10-24
    • 2018-07-20
    • 2011-01-01
    • 2014-01-08
    • 2012-12-04
    • 2017-11-01
    • 2016-05-29
    相关资源
    最近更新 更多