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

匿名 (未验证) 提交于 2019-12-03 02:51:02

问题:

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

回答1:

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 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!