I have two entities, lets call them A and B, which have a ManyToOne mapping to another entity, say C
So I typically have something like this:
a1->c
a2->c
b1->c
Lots of A's and B's pointing to the same C.
How do I get Hibernate to remove c when I remove the last a and b?
It seems that JPA/Hibernate does not support this. Which is really bad.
There is an attribute delete-orphan that you can use when mapping the many-to-one relation, this should do the work for you.
for more info. I advise visiting they documentation online about the cascading operations.