0

I read here What is the difference between cascade & inverse in hibernate, what are they used for? that

"In case of many-to-many relation through intermediary table; "Cascade" says whether record will be created/updated in child table. Whereas "Inverse" says whether record will be created/updated in intermediary table"

and the explanation was really good, I got it .. But this is many-to-many case.what is the use of cascade and inverse (or what is the difference between Cascade and inverse) in case of one-to-many and many-one relationships?

Community
  • 1
  • 1
Just_another_developer
  • 5,737
  • 12
  • 50
  • 83

1 Answers1

1

In case of one-to-many relation:

  • "Cascade" says whether the operation (save/update/delete/refresh...) will also be invoked on the childs
  • "Inverse" says whether the foreign key column will be set/updated by the entity containing the collection or not. Inverse="true" assumes that the child object has a backreference and the child will set/update the foreignkeycolumn when it is saved/updated
Firo
  • 30,626
  • 4
  • 55
  • 94