I'm a hibernate newbie and I'm not entirely sure how to get the cascade behavior I'm looking for.
Let's say I have two classes A and B with bi-directional many-to-many mappings to each other. A is the owner side and B is the inverse side (I hope I have the terminology correct).
public class A
{
private Set<B> bSet = new HashSet<B>();
@ManyToMany(targetEntity=B.class, cascade=CascadeType.?)
public Set<B> getBSet()
{
return bSet;
}
}
public class B
{
private Set<A> aSet = new HashSet<A>();
@ManyToMany(mappedBy="bSet", targetEntity=A.class, cascade=CascadeType.?)
public Set<B> getBSet()
{
return bSet;
}
}
I want to select the correct cascade type so that when I delete an A object, any B object containing it is updated and vice-versa.
Which cascade type(s) do I need here?