What is the difference between CascadeType.REMOVE and orphanRemoval in JPA?

From here:- Cascading Remove Marking a reference field with CascadeType.REMOVE (or CascadeType.ALL, which includes REMOVE) indicates that remove operations should be cascaded automatically to entity objects that are referenced by that field (multiple entity objects can be referenced by a collection field): @Entity class Employee { : @OneToOne(cascade=CascadeType.REMOVE) private Address address; : } Orphan Removal … Read more

How does JPA orphanRemoval=true differ from the ON DELETE CASCADE DML clause

orphanRemoval has nothing to do with ON DELETE CASCADE. orphanRemoval is an entirely ORM-specific thing. It marks “child” entity to be removed when it’s no longer referenced from the “parent” entity, e.g. when you remove the child entity from the corresponding collection of the parent entity. ON DELETE CASCADE is a database-specific thing, it deletes … Read more