Unfortunately, Oracle (at least the version I'm using) does not support automatic cascading deletes. Should child records be deleted separately before parent records are deleted in order to avoid restriction violations?
When deleting the parent object with the CascadeType.DELETE parameter on @OneToMany, when Hibernate decides to delete each child instance one by one and delete by foreign key in the package.
For instance,
PARENT table:
PARENT_ID
1
2
CHILD:
CHILD_ID PARENT_ID
eleven
2 1
3 2
Removing a parent can cascade the removal of children in two ways:
delete from CHILD where child_id = 1
delete from CHILD where child_id = 2
delete from PARENT where parent_id = 1
or
delete from CHILD where parent_id = 1
delete from PARENT where parent_id = 1
, Hibernate . , Hibernate , . , , , . , ConstraintViolationException, , .