Orphan removal and Cascade.REMOVE
Cascade.ALL is used to apply all operations on the children table which are getting applied on parent Operation includes - Delete - If parent is deleted then all children will be deleted. - Persist - If parent is persisted then all children will be persisted. - Update/Merge - If parent is updated then all changes in each children will be updated. - Reload - If you reload parent from DB, all children will be reloaded. - Detach - If parent is detached from the hibernate session all children will also be detached. ⚠️ The Danger Zone CascadeType.ALL is powerful but can be risky: - Accidental Deletes: If you delete a Department, you might delete 500 Employees you didn't mean to. - Performance: If you have a massive list, a simple update to the Parent might trigger checks/updates on every single Child. - Global Impact: It is usually better for Composition (where the child can't exist without the parent, like an Invoice and InvoiceItems). ⚠️ Wh...