【发布时间】: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 类匹配即可!
【问题讨论】:
-
究竟是什么问题?