This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Bad cascade

 
Mike Okri
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic