表在HQL查询中未映射

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

Table is not Mapped In HQL query

问题

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

我的课堂开始于:

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

我的HQL查询:

  1. List<ValidateInfo> lResult = null;
  2. String lHql = " from ValidateInfo vi "
  3. + " where vi.document.idDocument in (:documentsList) "
  4. + " and vi.idEntityType = :idEntityType";
  5. Query lQuery = pSession.createQuery(lHql);
  6. lQuery.setParameterList("documentsList", pDocumentsList);
  7. lQuery.setParameter("idEntityType", pIdEntityType);
  8. lResult = lQuery.list();

我得到的错误:

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

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

英文:

My class begins with:

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

And my HQL Query:

  1. List&lt;ValidateInfo&gt; lResult = null;
  2. String lHql = &quot; from ValidateInfo vi &quot;
  3. + &quot; where vi.document.idDocument in (:documentsList) &quot;
  4. + &quot; and vi.idEntityType = :idEntityType&quot;;
  5. Query lQuery = pSession.createQuery(lHql);
  6. lQuery.setParameterList(&quot;documentsList&quot;, pDocumentsList);
  7. lQuery.setParameter(&quot;idEntityType&quot;, pIdEntityType);
  8. lResult = lQuery.list();

The error I get:

  1. [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]
  2. [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查询时,必须编写所使用类的完整路径。

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

  1. String lHql = " from " + ValidateInfo.class.getName() + " vi "
  2. + " where vi.document.idDocument in (:documentsList) "
  3. + " 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:

  1. String lHql = &quot; from &quot; + ValidateInfo.class.getName() + &quot; vi &quot;
  2. + &quot; where vi.document.idDocument in (:documentsList) &quot;
  3. + &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:

确定