1

Is inverse=true applicable only for insert operation if relationship is updated by the owner in the case of one-to-many bidirectional relation ship. It is applicable for delete and update as well?.

user3094331
  • 532
  • 6
  • 21

1 Answers1

2
  • It's much simpler: If you map the same foreign key column twice, you need to "disable" one side by making it inverse. Which side varies.

  • If I have a one-to-many with a persistent List or Map, I'd make that side inverse="false" and the many-to-one should be disabled for updating/insertion with insert="false" and update="false".

  • If I have one-to-many with a persistent Set, I'd make that side inverse="true" and let the many-to-one update/insert the foreign key column.

  • If I have a many-to-many with a persistent Set on both sides, I can pick which side is "disabled", no difference.

  • If I have a many-to-many with a persistent List or Map on one of the sides, I need to enable that side and disable the other side (otherwise the index/map key of that list or map isn't stored.)

ssc-hrep3
  • 15,024
  • 7
  • 48
  • 87
Gokul
  • 931
  • 7
  • 16
  • Can u suggest me some references or books to get more understanding on bidirectional relational ships as well as cascades and inverse. – user3094331 Jul 20 '16 at 09:01
  • Check out the below given link http://www.mkyong.com/hibernate/inverse-true-example-and-explanation/ http://stackoverflow.com/questions/3667387/what-is-the-difference-between-cascade-inverse-in-hibernate-what-are-they-use – Gokul Jul 20 '16 at 09:22