[英]Table is not Mapped In HQL query
My class begins with:我的 class 开头是:
@Entity
@Table(name = "validate_info", catalog = "company")
@JsonIdentityInfo(generator=ObjectIdGenerators.IntSequenceGenerator.class, property="@id")
public class ValidateInfo implements java.io.Serializable{
And my HQL Query:还有我的 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();
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.我不知道为什么会出现“未映射”错误,HQL 查询表的名称与类名相同。
When you write an HQL
query you must write the complete path of your used class.当您编写HQL
查询时,您必须编写您使用的 class 的完整路径。
So you can replace your code as follow:因此,您可以按如下方式替换您的代码:
String lHql = " from " + ValidateInfo.class.getName() + " vi "
+ " where vi.document.idDocument in (:documentsList) "
+ " and vi.idEntityType = :idEntityType";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.