您的位置:首页 > 其它

关于Hibernate:No row with the given identifier exists报错的解决办法

2015-12-15 09:36 387 查看
我们在用many-to-one配置关联的时候,有时关联查询会报No row with the given identifier exists的错误,究其原因是数据不完整(关联的对象值为null),产生脏数据。对此解决这个报错信息的方法一般有两个:

一、改数据

找到脏数据源头,删除或更改,不过个人不怎么建议使用这个方法。

二、在many-to-one配置的时候将策略为忽略。

由于在配置many-to-one的时候,没有配置not-found属性,该属性值就默认为Exception,也就是抛出异常,我们只将这个属性值改为ignore即可(忽略)。例如

<many-to-one
name="conPo"
class="com.keda.project.peijian.inproc.po.KedaPjInprocConsmatmain"
fetch="select"
lazy="false"
not-null="false"
**not-found="ignore"**
column="conid"
insert="false"
update="false"
/>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: