Hibernate version:3.1.3
Name and version of the database you are using:Posgtres
Hi
i have setup a parent child mapping which is working, I can save and update both which works well. I am using inverse='true' and a many-to-one mapping with cascade = all-delete-orphan
But my issue comes about when i want to move a child from one parent to another.
If I do
parent.getchildren.remove (child)
child.setparent(newparent)
newparent.getchildren.add(child)
hibernate throws an exception becuse it has queued and event to delete the child, from the first remove.
What i have to do is something like this
session.begintransaction
child.setparent(newparent)
newparent.getchildren.add(child)
session.gettrans.committrans()
session.refresh(parent)
I can't use remove cause this will cause a delete event to be queued.
but my problem if i have a 1000children this become very expensive.
Is there a way around this, or do I have to change my cascade to not include delete-oprhan ?
Alex
|