首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Hibernate错误No row with the given identifier exists 解决办法

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

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 。

热点排行