Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hibernate many-to-many

 
Larry Jones
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do you delete and update a many-to-many relationship in hibernate without deleting the two related objects from the db; that is, I just want to remove the entry in the many-to-many table that joins the two objects, not the two objects themselves.

Thanks for the help
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65221
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to ORM.
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't used many-to-many relationships with Hibernate yet, but I can make an educated guess.
  • Load one of the objects (A).
  • Find the other object (B) in A's collection of Bs.
  • Remove B from the collection.
  • Save A.


  • I don't think you'll need to do the same from the other side, or if it depends on whether or not it's an inverse association, or if N:N relations can even be inverse.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic