当前位置: 代码迷 >> J2EE >> hibernate中one-to-many双向中关于update的有关问题
  详细解决方案

hibernate中one-to-many双向中关于update的有关问题

热度:81   发布时间:2016-04-22 03:11:34.0
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进去即可
  相关解决方案