表在HQL查询中未映射

huangapple go评论71阅读模式
英文:

Table is not Mapped In HQL query

问题

以下是您提供的内容的翻译:

我的课堂开始于:

@Entity
@Table(name = "validate_info", catalog = "company")
@JsonIdentityInfo(generator=ObjectIdGenerators.IntSequenceGenerator.class, property="@id")
public class ValidateInfo implements java.io.Serializable{

我的HQL查询:

List<ValidateInfo> lResult = null;

String lHql = " from ValidateInfo vi "
				+ " where vi.document.idDocument in (:documentsList) "
				+ " and vi.idEntityType = :idEntityType";

Query lQuery = pSession.createQuery(lHql);
lQuery.setParameterList("documentsList", pDocumentsList);
lQuery.setParameter("idEntityType", pIdEntityType);
lResult = lQuery.list();

我得到的错误:

[T0028][SEVERE] .web.Control.execute() RunService返回异常 ValidateInfo未映射 [ from ValidateInfo vi  where vi.document.idDocument in (:documentsList)  and vi.idEntityType = :idEntityType]
[T0028][SEVERE] .web.Control.manageError()  java.util.HashMap无法转换为java.util.List

你们能帮我吗?我不知道为什么会出现“未映射”错误,HQL查询表的名称与类名相同。

英文:

My class begins with:

@Entity
@Table(name = &quot;validate_info&quot;, catalog = &quot;company&quot;)
@JsonIdentityInfo(generator=ObjectIdGenerators.IntSequenceGenerator.class, property=&quot;@id&quot;)
public class ValidateInfo implements java.io.Serializable{

And my HQL Query:

		List&lt;ValidateInfo&gt; lResult = null;

		String lHql = &quot; from ValidateInfo vi &quot;
						+ &quot; where vi.document.idDocument in (:documentsList) &quot;
						+ &quot; and vi.idEntityType = :idEntityType&quot;;

		Query lQuery = pSession.createQuery(lHql);
		lQuery.setParameterList(&quot;documentsList&quot;, pDocumentsList);
		lQuery.setParameter(&quot;idEntityType&quot;, pIdEntityType);
		lResult = lQuery.list();

The error I get:

[T0028][SEVER] .web.Control.execute() RunService returns Exception  ValidateInfo is not mapped [ from ValidateInfo vi  where vi.document.idDocument in (:documentsList)  and vi.idEntityType = :idEntityType]
[T0028][SEVER] .web.Control.manageError()  java.util.HashMap cannot be cast to java.util.List

Can you guys help me? I don't know why i get the "not Mapped" error, the name of the HQL query table is the same as the classname.

答案1

得分: 2

当您编写HQL查询时,必须编写所使用类的完整路径。

因此,您可以将您的代码替换为以下内容:

String lHql = " from " + ValidateInfo.class.getName() + " vi "
    + " where vi.document.idDocument in (:documentsList) "
    + " and vi.idEntityType = :idEntityType";
英文:

When you write an HQL query you must write the complete path of your used class.

So you can replace your code as follow:

String lHql = &quot; from &quot; + ValidateInfo.class.getName() + &quot; vi &quot;
+ &quot; where vi.document.idDocument in (:documentsList) &quot;
+ &quot; and vi.idEntityType = :idEntityType&quot;;

huangapple
  • 本文由 发表于 2020年5月4日 17:15:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/61588795.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定