File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Bad cascade Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Bad cascade" Watch "Bad cascade" New topic
Author

Bad cascade

Mike Okri
Ranch Hand

Joined: Jun 22, 2011
Posts: 83
I have a many-to-many mapping between student and course and I have cascade="all" on the students-to-courses mapping as shown below. When I delete a student, hibernate cascades the delete to all of the students courses. My problem is that some of these deleted courses are also shared by other students. How do I ensure that deleting student_A will delete only courses that belong only to student_A and not courses that are shared with student_B.


Ogeh Ikem
Ranch Hand

Joined: May 13, 2002
Posts: 180
cascade="all", cascade="delete", and cascade="all-delete-orphans" should be avoided when dealing with many-to-many associations, or else, problems like this will arise.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Bad cascade
 
Similar Threads
Bi-directional mapping problems while creating tables on runtime
Hibernate mapping problem
one-to-many mapping...
Bi-directional mapping problems while creating tables on runtime
java.lang.IllegalArgumentException argument type mismatch