Can you model this for us and give us a better picture of class structure and mapping? I'm confused by "false parent" for one. Should a false parent be able to cascade delete? It sounds a bit circular. If nothing else you have a nasty custody batle on your hands.
Shouldn't cascade="all-delete-orphan" be on the child, as well as inverse="true"? In this case, if I remove a child from a collection on the parent, it's deleted from the repository. Still unsure what would happen with 2 parents (would have to test).
So, in a nutshell:
If I put inverse="true" on a child, adding the child to a collection on the parent would create a new one by saving the child after associating the two...
Code:
Parent parent = parentDao.Get(parentId);
Chile child = new Child(); //child has prentId in database
child.Parent = parent;
parent.Children.Add(child);
session.Save(child);
session.Flush(); //A child is born! (using one insert)
Now if I add inverse="true" and cascade="all" to the Parent's collection of Children we wouldn't need the explicit save:
Code:
Parent parent = parentDao.Get(parentId);
Chile child = new Child(); //child has prentId in database
child.Parent = parent;
parent.Children.Add(child);
session.Flush(); //A child is born!
Given this, if I delete the parent, all the children get deleted with it. But, if I remove a child from the parent.Children collection, the association is severed and the child is orphaned and still in the database without the association to the parent (if a not null constraint wasn't violated first).
If a child can't exist without a parent, then we use cascade="all-delete-orphan" on the child so that if the child is removed from parent.Children then it is deleted from the database (because we euthanise all orphans).
Make sense?