Lets say we have two Entities, Entity Node
and Entity Cluster
.
A Cluster
has many Node
s. A Node
can belong to multiple Cluster
. So in Cluster
there is a @ManyToMany
annotation. However Node
is unaware of any Cluster
it belongs to (intentional).
When I delete a Cluster
I want to keep all the Node
s (in future I may add those Node
s to another Cluster
) it had. So I don't need Cascade.DELETE
. But If I delete a Node
, all the Cluster
it belonged to should be updated (the Node
will be removed from them).
What is the best way to handle this using JPA ?