Bue wrote:
Suppose we have a parent/child relationsship and a bidirectional mapping properly set.
When I load a parent object I also get a list of all childs. Now I want to delete the parent and all it associated childs. But in the meantime another user has added an new child to the same parent. So this child is not in the child list of my parent object.
My question: When I delete the parent, will the new child of the other user also be deleted or will Hibernate delete only those childs which are in the parents child list? How to deal with such situations?
Thanks for your help
Bruno
Bruno,
If you're using cascade="delete-orphan" on the child-set, I'm 99% sure that the delete query that gets created is something like "delete from child where parentId = ?" so it would also delete the new child.