调用hibernate的update方法报org.hibernate.MappingException: Unknown entity:错误
小弟昨天看着这个错误,直接反映就是映射出错,调式了快一上午的时间一直报这个错误。大怒,先贴出原本的代码。方便以后记住
xml配置
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD
3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Generated 2007-4-17 14:04:58 by Hibernate Tools 3.2.0.beta8
-->
<hibernate-mapping>
<class
name="com.yinzhijie.docproc.domain.ParamCreditSet"
table="Param_Credit"
dynamic-insert="true" dynamic-update="true"
entity-name="ParamCreditSet">
<id name="autoId"
type="long">
<column name="AutoID" />
<generator
class="native">
<param
name="sequence">PARAMCREDIT_AUTOID</param>
</generator>
</id>
<property
name="creditId" type="string">
<column name="CreditID" length="40"
not-null="true" />
</property>
<property
name="creditValue" type="java.lang.Long">
<column
name="CreditValue" />
</property>
<property
name="creditMemo" type="string">
<column name="CreditMemo"
length="256" />
</property>
<property name="dupdDate"
type="string">
<column name="DupdDate" length="10"
/>
</property>
<property name="cupdOperator"
type="string">
<column name="CupdOperator" length="10"
/>
</property>
<property name="bankCode"
type="java.lang.Long">
<column name="BankCode"
/>
</property>
<property name="orgNoOperator"
type="string">
<column name="OrgNoOperator" length="64"
/>
</property>
<property name="bankName"
type="string">
<column name="BankName" length="80"
/>
</property>
<property name="centerId"
type="string"> <!-- 联社代号lsCode -->
<column name="CenterId"
length="64" />
</property>
<property name="updateDate"
type="string">
<column name="UpdateDate" length="10"
/>
</property>
</class>
</hibernate-mapping>
对应的实体对象
public class ParamCreditSet implements java.io.Serializable{
/**
*
*/
private static final long serialVersionUID =
-8058539208673220927L;
private long autoId;
private String
creditId;
private long creditValue;
private String
creditMemo;
private String dupdDate;
private String
cupdOperator;
private String orgNoOperator;
private String
bankName;
private String centerId;
private String
updateDate;
private long bankCode;
调用的impl
public class ParamCreditSetAdm extends BaseService<ParamCreditSet>
implements
IParamCreditSetAdm {
@Override
public void updateVaules(ParamCreditSet paramCreditSet) throws
XDocProcException {
// TODO Auto-generated method stub
/*String sql =
"update Param_Credit set CreditValue = "+paramCreditSet.getCreditValue()+" where
autoId = "+paramCreditSet.getAutoId();
SQLQuery query =
dao.getSessionFactory().openSession().createSQLQuery(sql);
int f =
query.executeUpdate();
if(f ==
1){
System.out.println("更新成功!");
}*/
dao.update(paramCreditSet);
}
}
我也检查了<property name="mappingResources">也没发现路径不对之类的,反正百度谷歌出来的都试了,都不行
就做 了以下测试在impl里做调式
public class ParamCreditSetAdm extends BaseService<ParamCreditSet>
implements
IParamCreditSetAdm {
@Override
public void updateVaules(ParamCreditSet paramCreditSet) throws
XDocProcException {
// TODO Auto-generated method stub
String sql =
"update Param_Credit set CreditValue = "+paramCreditSet.getCreditValue()+" where
autoId = "+paramCreditSet.getAutoId();
SQLQuery query =
dao.getSessionFactory().openSession().createSQLQuery(sql);
int f =
query.executeUpdate();
if(f ==
1){
System.out.println("更新成功!");
}
//dao.update(paramCreditSet);
}
}
发现可以进行更新,没有报错了。就直接到xml里找了发现原来是自己大意了
把xml里entity-name="ParamCreditSet" 去掉就万事大吉。蛋疼了很久。
调用hibernate的update方法报org.hibernate.MappingException: Unknown entity:错误,,5-wow.com
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。