Reading refernce docs at:
http://www.hibernate.org/hib_docs/v3/re ... hild-bidir
I'm wondering whether the following method is incomplete:
public void addChild(Child c) {
c.setParent(this);
children.add(c);
}
What if Child c already had a parent? After the method we will have two Parents with children arrays both referencing Child c, although c will only point to the newer Parent. Shouldn't the method be:
public void addChild(Child c) {
Parent oldParent = c.getParent();
if(oldParent != null)
{
oldParent.remove(c);
}
c.setParent(this);
children.add(c);
}
thanks
-nikita