0

I have found lots of example for hibernate one to many insert operation but I am looking for best practice for update, delete and select for one to many (parent-child) relation.

I am looking for solution that child object automatically insert, delete-insert(Update case) and delete when parent object delete.

Punit Patel
  • 901
  • 1
  • 12
  • 25
  • @OneToMany(cascade=CascadeType.ALL) – white May 08 '13 at 05:42
  • It insert childs record in child table, but in update case it not delete-insert child objects, it insert new childs in child table and if we configure inverse true then it set parentid to null in old child object data. Please share one example of update one to many relation. – Punit Patel Jun 18 '13 at 09:50
  • There is also orphanRemoval=true in JPA2.0 for xToMany relations, see [thread 306144](http://stackoverflow.com/questions/306144/jpa-cascadetype-all-does-not-delete-orphans) for more details – white Jun 18 '13 at 15:26
  • When use annotation it works properly but for hbm it not working properly even i set cascade to all-delete-orphan. – Punit Patel Jun 19 '13 at 09:45

0 Answers0