hibernate中one-to-many双向中关于update的问题
在更新事件中,怎么做到只能信主表而从表不动。
- XML code
<set name="photo" table="face_standard_photo" lazy="false" inverse="false" cascade="all"> <key> <column name="PERSONNELID" not-null="true"/> </key> <one-to-many class="com.face.ORM.FaceStandardPhoto"/></set>
- XML code
<many-to-one name="doubtful" column="PERSONNELID" class="com.face.ORM.FaceDoubtful" not-null="true" lazy="false" cascade="none" />
如何解决
[解决办法]
学习一下
[解决办法]
one-to-many中在one的一边
cascade="none"
[解决办法]
将<set></set>中的inverse值设置成"true"即可
[解决办法]
我也遇到过类似的情况,你可以先把这个实体取回来然后将其直属信息set进去即可