Remove orphans with JPA/Hibernate in opposite direction

27 Views Asked by At

I'm struggling with this problem:

It is quite difficult in JPA/Hibernate to remove an orphaned child from multiple parents. When the relation is: multiple-parent > multiple-children there is no issue and orphanRemoval = true works as expected.

But in our situation we have multiple parent locations with a single child city. How to do this? Perhaps reversing the relation? A 'parent'-city has multiple 'child'-locations or something? How would this work if the 'child'-location is also referenced by 'parent'-provinces for example.

I tried to Google for answers but didn't came across this one.

0

There are 0 best solutions below