[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-785) Persistence through cascading should have higher precedence than orphan-delete
Joe Kelly (JIRA)
noreply at atlassian.com
Tue May 15 16:50:04 EDT 2007
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-785?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_26958 ]
Joe Kelly commented on HHH-785:
-------------------------------
I realize this issue is closed but I wanted to put in my two cents. I totally agree with Christian's argument: persistence through cascading should indeed have higher precedence than orphan-delete. As Christian says, without this feature, you must resort to complex session coding to relocate a node.
Christian's code example seems to be the most natural and transparent way to relocate a node, but it doesn't work, of course:
a.remove(b);
c.add(b);
session.flush();
The following code works but seems less natural and transparent, in my opinion:
b.setParent(c);
session.flush();
session.refresh(a);
session.refresh(c);
> Persistence through cascading should have higher precedence than orphan-delete
> ------------------------------------------------------------------------------
>
> Key: HHH-785
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-785
> Project: Hibernate3
> Issue Type: Improvement
> Components: core
> Affects Versions: 3.1 beta 1
> Reporter: Christian Bauer
>
> A typical tree mapped using an adjacency list:
> <many-to-one name="parent" cascade="none"/>
> <set name="children" cascade="all, delete-orphan"/>
> A normal tree operation is moving a node:
> a.remove(b);
> c.add(b);
> This results in an exception, as Hibernate currently rates the delete-orphan as more important and warns that the node would become persistent again through cascading. However, this is the only way to implement relocation of a node in a tree without resorting to complex session coding. I argue that the "delete orphans" guarantee given in the mapping should not have precedence over the the actual non-orphaned persistent state in the Session.
--
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
More information about the hibernate-issues
mailing list