Search code examples
javahibernateresthql

HTTP Status 500 - No data type for node: org.hibernate.hql.internal.ast.tree.IdentNode


I know this question has been asked a lot of times. I have searched the entire Stack Overflow, but haven't been able to get much out of it. I understand that this exception arises when the column name used in the query is different than the property specified in the bean class, however, both of my parameters are the same.

Complete Error:

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

This is my query:

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

And this is my bean class:

@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;  

The query runs for ALL the parameters except for iduserInfo and idquestions. My column names in the table have exactly same parameters, although I read it somewhere that it doesn't matter, you only need to match your parameters with the bean classes!


Solution

  • I solved the issue by changing the column names "iduserInfo" and "idquestion" to "user" and "question" respectively. I think the reason for this is that there is already a parameter with "id". I don't understand why this was causing the problem, but changing the column name to something that was not even remotely to the parameter "id" did the trick for me!