From: Aaron D. (JIRA) <no...@at...> - 2006-07-11 14:46:57
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1894?page=comments#action_23595 ] Aaron Digulla commented on HHH-1894: ------------------------------------ To make this code work, just replace "all-delete-orphans" in the mapping file with "all". But now, you have to manage orphans (objects which have been removed from the parent but not attached anywhere else), manually! > moving child between parents in tree-like structure > --------------------------------------------------- > > Key: HHH-1894 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1894 > Project: Hibernate3 > Type: Bug > Components: core > Versions: 3.1.3 > Environment: HSQLDB 1.8.0.4 > Reporter: Aaron Digulla > Attachments: parentchild.zip > > > After asking in the forum, I was directed here. I'm not sure if the bug is in Hibernate or in my code. If it's in my code, I'd suggest to change this bug report into an enhancement request and add my code to the test suite of Hibernate as an example. > Basically, I have a tree-like structure and I want to move a node between parents. Here is the implementation of Node.setParent(): > public void setParent(Node parent) > { > if (this.parent != null) > this.parent.getChildren().remove(this); > > this.parent = parent; > > if (this.parent != null) > this.parent.getChildren().add(this); > } > When I try this, I get: > org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations): [org.hibernate.parentchild.Node#2] > in Session.flush(). > I tried many different ways to implement this (see the test case) but in the end, the only solution I found was to clone the child, delete it manually(!) and create a new object. > This issue was discussed in the forum: http://forum.hibernate.org/viewtopic.php?t=961777 > This might be a regression from 3.0 (see issue HHH-273) -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |