休眠映射:
User.hbm.xml
<hibernate-mapping package="com.user">
<class name="User" lazy="true" table="USER">
<set name="StudentOrganizations" inverse="true" cascade="all-delete-orphan" fetch="select" sort="natural">
<key>
<column name="STUDENT_ID" not-null="true" />
</key>
<one-to-many class="com.StudentOrganization" />
</set>
</class>
StudentOrganization.hbm.xml
<hibernate-mapping>
<class name="com.StudentOrganization" table="USER_ORGANIZATION">
<cache usage="read-write" />
<many-to-one name="user" class="com.User" update="false" insert="false" fetch="select">
<column name="STUDENT_ID" not-null="true" />
</many-to-one>
<many-to-one name="organization" class="com.Organization" update="false" insert="false" fetch="select">
<column name="ORGANIZATION_ID" not-null="true" />
</many-to-one>
</class>
</hibernate-mapping><BR>
更新学生记录时的伪代码。
myDAO.detach(myOldDetails);
myDAO.merge(aResource);
在更新学生详细信息时,我收到错误
"deleted object would be re-saved by cascade (remove deleted object from associations): [com.StudentOrganization]....."