Java 节点没有数据类型:org.hibernate.hql.internal.ast.tree.IdentNode HQL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26471534/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
No data type for node: org.hibernate.hql.internal.ast.tree.IdentNode HQL
提问by krs8785
I have the HQL where I trying to get artifacts that have no classification (when active is 0)
我有 HQL,我试图获取没有分类的工件(当活动为 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 1and Quest 2
采纳答案by Vimm
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.
SQL 查询使用列名,而 HQL 查询使用类属性。您正在从分类中选择 artifact_id,但分类类没有名为“artifact_id”的属性。要修复它,请在您的 HQL 中使用 class 属性。
SELECT artifactId FROM Classification
回答by Tejas Pawar
It occurs sometimes when keyword 'new' is missed for your DTO (DATA TRANSFER OBJECT).
当您的 DTO(数据传输对象)缺少关键字“新”时,有时会发生这种情况。