Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No data type for node: org.hibernate.hql.internal.ast.tree.IdentNode HQL

I have the HQL where I trying to get artifacts that have no classification (when active is 0)

artifacts = Artifact.findAll("FROM Artifact WHERE id NOT IN ( SELECT artifact_id FROM Classification WHERE active = 1) AND document_id = :docid",[docid:document.id], [max:limit, offset:startIndex]); 

Whenever I run I get the error

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

Classificaiton definition:

class Classification {      public static final String USER_DEFAULT = "USER"     public static final String USER_SYSTEM = "SYSTEM"      TaxonomyNode node     String artifactId      Boolean active     String createdBy     String updatedBy     Date dateCreated     Date lastUpdated       static constraints = {         node nullable:false, blank:false         artifactId nullable:false, blank:false, unique: ['node']         active nullable: false, blank: false         createdBy nullable:false, blank:false         updatedBy nullable:false, blank:false     }      static mapping = {         id generator:'sequence', params:[sequence:'classification_seq']         artifactId index: 'classify_by_artifact_node'         node index: 'classify_by_artifact_node'         active defaultValue: "1"     } } 

You can refer to previous problems I faced to understand what exactly I am trying to do Quest 1 and Quest 2

like image 948
krs8785 Avatar asked Oct 20 '14 17:10

krs8785


2 Answers

SQL queries use column names while HQL queries use Class properties. You're selecting artifact_id from Classification but the Classification class has no property named 'artifact_id'. To fix it, use the class property in your HQL.

SELECT artifactId FROM Classification 
like image 191
Vimm Avatar answered Oct 02 '22 10:10

Vimm


It occurs sometimes when keyword 'new' is missed for your DTO (DATA TRANSFER OBJECT).

like image 42
Tejas Pawar Avatar answered Oct 02 '22 09:10

Tejas Pawar