0

Hibernate Mappings:

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>

Pseudocode while updating Student Record.

myDAO.detach(myOldDetails);
myDAO.merge(aResource);

while updating the student details I get error as "deleted object would be re-saved by cascade (remove deleted object from associations): [com.StudentOrganization]....."

Krishna
  • 321
  • 1
  • 6
  • 15
  • while updating the student details i get error as "deleted object would be re-saved by cascade (remove deleted object from associations): [com.StudentOrganization]....." – Krishna Sep 27 '13 at 06:55

1 Answers1

0

Here is a similar question.

Hope.. adding fetchType=lazy will solve your problem.

Community
  • 1
  • 1
DarkHorse
  • 2,740
  • 19
  • 28