读书人

Hibernate错误No row with the given

发布时间: 2012-08-27 21:21:56 作者: rapoo

Hibernate异常No row with the given identifier exists 解决方法
http://zyc-to.blog.163.com/blog/static/1715240020096176461070/


这个异常是在 多对一关系映射时,一方表中对应的数据不存在才抛出的。
原来的配置:
<many-to-one fetch="join" name="userInfo" >
<column name="userId" unique="true"/>
</many-to-one>

修改后的:
<many-to-one fetch="join" name="userInfo" not-found="ignore">
<column name="userId" unique="true"/>
</many-to-one>

红色是修改的部分。意思是当对应的数据不存在时 忽略掉,用null值填充。该属性默认值:exception 。

读书人网 >软件架构设计

热点推荐