Reputation: 571
i have a simple one to many mapping in my project...let's suppose that i have 1 father object and 3 child objects stored in my DB. the problem occurs when i load the father object and change the number of sons (for example removing one of them). When i try to update the father object, the son that is no longer in the child's set it's still on the DB. Is there a way to delete the unwanted child without have to manually proceed?
Upvotes: 3
Views: 2379
Reputation: 1238
You can use the attribute orphanRemoval=true
on the @OneToMany annotation.
Upvotes: 2