Suppose that we have 3 Entities object class:
class Parent {
String name;
List<Child> children;
}
class Child {
String name;
Parent parent;
}
class Toy {
String name;
Child child;
}
How can I use JPA2.x (or hibernate) annotations to:
- Delete all children automatically when parent delete (one to many)
- Delete child automatically from children list when it is deleted (many to one)
- Delete toy automatically when child remove (one to one)
I'm using Hibernate 4.3.5 and mysql 5.1.30.
Thanks