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

many-to-one避免出现No row with the given identifier exists的配备方法

2012-10-30 
many-to-one避免出现No row with the given identifier exists的配置方法如下:表Space的Space.hbm.xml文件

many-to-one避免出现No row with the given identifier exists的配置方法

如下:

表Space的Space.hbm.xml文件中关联了创建者的对象builder,这时在many-ton-one中设置fetch="join"和not-null="true",这时产生的sql语句就变成了内联查询inner join而不是左外联查询,这样就可以避免在查询中遇到关联的对象为null的情况了(比如关联的用户已经被删除,但是Space的数据没有删除掉)

?<many-to-one name="builder" column="userId"
??? ??? ??? lazy="false" insert="false"
??? ??? ??? update="false" fetch="join" not-null="true">
?</many-to-one>

热点排行