Consider the following scenario where we have three objects (B,C,D)
referring to object A.
Code:
@Entity
class A {
}
@Entity
class B {
private List<A> a;
}
@Entity
class C {
private List<A> a;
}
@Entity
class D {
private A a;
}
Suppose I would like to remove an A instance using
Code:
entityManager.remove(a);
This means that I have to first remove all references from B and C to my a instance otherwise the removal will fail. With D I would have to set a == null or remove the D instance.
What I want to know is if there are any best practices, patterns or even some hibernate support for this that I am unaware of?
Kind regards
/Johan