使用hibernate时如果提示映射不对时可能是以下原因

分享 未结 0 1551
邮箱用户_b2v3t
邮箱用户_b2v3t LV1 2020年6月25日 19:30 发表

根据HQL得到一个数据对象时出错:ZYExam is not mapped [From ZYExam AS z WHERE z.lZhuanYeId = 4 AND z.lExamInfoId=1718]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: ZYExam is not mapped [From ZYExam AS z WHERE z.lZhuanYeId = 4 AND z.lExamInfoId=1718]


package net.pthl.SAASProduct.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import javacommon.core.base.BaseEntity;

/**
* 1:---专业考试表/多对多关系。
* 2:---自己维护:---因为要在表中加个成绩字段/维护成绩
*
* @author wangchh
*
*/
@Entity(name = "ZY_Exam")
@Table(name = "ZY_Exam")
public class ZYExam extends BaseEntity
{
/**
* 序列化ID。
*/
private static final long serialVersionUID = 8295041166614311961L;

/**
* 字段常量信息。
*/
public static final String ID = "lId";
public static final String ZYID = "lZhuanYeId";
public static final String EID = "lExamInfoId";
public static final String SCORE = "strScore";
public static final String SCORE_STATUS = "nScoreStatus";
public static final String RESERVER1 = "strReserver1";
public static final String RESERVER2 = "strReserver2";
public static final String RESERVER3 = "strReserver3";
public static final String RESERVER4 = "strReserver4";

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID", nullable = false)
private Long lId;// 专业考试表ID

@Column(name = "ZYID", nullable = false)
private Long lZhuanYeId;// ZhuanYe ID

@Column(name = "EID", nullable = false)
private Long lExamInfoId;// ExamInfo ID

@Column(name = "Score")
private String strScore;// 成绩

@Column(name = "Score_Status", nullable = false)
private int nScoreStatus;// 成绩申报的状态;未申报:0;已申报:1

/**
* 备用字段,用于扩展。
*/
@Column(name = "reserver1")
private String strReserver1;

/**
* 备用字段,用于扩展。
*/
@Column(name = "reserver2")
private String strReserver2;

/**
* 备用字段,用于扩展。
*/
@Column(name = "reserver3")
private String strReserver3;

/**
* 备用字段,用于扩展。
*/
@Column(name = "reserver4")
private String strReserver4;

/**
* 获取lId。
*
* @return the lId
*/
public Long getLId()
{
return lId;
}

/**
* 设置lId。
*
* @param lId the lId to set
*/
public void setLId(Long lId)
{
this.lId = lId;
}

/**
* 获取lZhuanYeId。
*
* @return the lZhuanYeId
*/
public Long getLZhuanYeId()
{
return lZhuanYeId;
}

/**
* 设置lZhuanYeId。
*
* @param lZhuanYeId the lZhuanYeId to set
*/
public void setLZhuanYeId(Long lZhuanYeId)
{
this.lZhuanYeId = lZhuanYeId;
}

/**
* 获取lExamInfoId。
*
* @return the lExamInfoId
*/
public Long getLExamInfoId()
{
return lExamInfoId;
}

/**
* 设置lExamInfoId。
*
* @param lExamInfoId the lExamInfoId to set
*/
public void setLExamInfoId(Long lExamInfoId)
{
this.lExamInfoId = lExamInfoId;
}

/**
* 获取strScore。
*
* @return the strScore
*/
public String getStrScore()
{
return strScore;
}

/**
* 设置strScore。
*
* @param strScore the strScore to set
*/
public void setStrScore(String strScore)
{
this.strScore = strScore;
}

/**
* 获取scoreStatus。
*
* @return the scoreStatus
*/
public int getNScoreStatus()
{
return nScoreStatus;
}

/**
* 设置scoreStatus。
*
* @param nScoreStatus the scoreStatus to set
*/
public void setNScoreStatus(int nScoreStatus)
{
this.nScoreStatus = nScoreStatus;
}

/**
* 获取strReserver1。
*
* @return the strReserver1
*/
public String getStrReserver1()
{
return strReserver1;
}

/**
* 设置strReserver1。
*
* @param strReserver1 the strReserver1 to set
*/
public void setStrReserver1(String strReserver1)
{
this.strReserver1 = strReserver1;
}

/**
* 获取strReserver2。
*
* @return the strReserver2
*/
public String getStrReserver2()
{
return strReserver2;
}

/**
* 设置strReserver2。
*
* @param strReserver2 the strReserver2 to set
*/
public void setStrReserver2(String strReserver2)
{
this.strReserver2 = strReserver2;
}

/**
* 获取strReserver3。
*
* @return the strReserver3
*/
public String getStrReserver3()
{
return strReserver3;
}

/**
* 设置strReserver3。
*
* @param strReserver3 the strReserver3 to set
*/
public void setStrReserver3(String strReserver3)
{
this.strReserver3 = strReserver3;
}

/**
* 获取strReserver4。
*
* @return the strReserver4
*/
public String getStrReserver4()
{
return strReserver4;
}

/**
* 设置strReserver4。
*
* @param strReserver4 the strReserver4 to set
*/
public void setStrReserver4(String strReserver4)
{
this.strReserver4 = strReserver4;
}

/**
* 获取lId。
*
* @return the lId
*/
public Long getlId()
{
return lId;
}

/**
* 设置lId。
*
* @param lId the lId to set
*/
public void setlId(Long lId)
{
this.lId = lId;
}

/**
* 获取lZhuanYeId。
*
* @return the lZhuanYeId
*/
public Long getlZhuanYeId()
{
return lZhuanYeId;
}

/**
* 设置lZhuanYeId。
*
* @param lZhuanYeId the lZhuanYeId to set
*/
public void setlZhuanYeId(Long lZhuanYeId)
{
this.lZhuanYeId = lZhuanYeId;
}

/**
* 获取lExamInfoId。
*
* @return the lExamInfoId
*/
public Long getlExamInfoId()
{
return lExamInfoId;
}

/**
* 设置lExamInfoId。
*
* @param lExamInfoId the lExamInfoId to set
*/
public void setlExamInfoId(Long lExamInfoId)
{
this.lExamInfoId = lExamInfoId;
}

/**
* 获取nScoreStatus。
*
* @return the nScoreStatus
*/
public int getnScoreStatus()
{
return nScoreStatus;
}

/**
* 设置nScoreStatus。
*
* @param nScoreStatus the nScoreStatus to set
*/
public void setnScoreStatus(int nScoreStatus)
{
this.nScoreStatus = nScoreStatus;
}

}

这个类中上面的@Entity(name = "ZY_Exam")与你的From后面的类名不对应的问题。

strHql = "From ZYExam AS z WHERE z.lZhuanYeId = " + objZhuanYe.getlId() + " AND z.lExamInfoId=" + objExamInfo.getlId();

收藏(0)  分享
相关标签: 笔记
问题没解决?让chatGPT帮你作答 智能助手
0个回复
  • 消灭零回复