In case anyone else has a similar issue, we were able to resolve this with the following actions:
1. Add a save-update cascade from [A] to [C] 2. Use [QB] as the handle to the object graph instead of the new instance of [C] My belief is that the 'best' way of handling complex cascades would be to order the graph operations by dependency using the cascade and nullability settings to determine the edges, but I haven't noticed any graph algorithms in the NH codebase. Is this a feature that people think would be worth implementing, or is it too far removed from the current methodology? /Pete From: [email protected] [mailto:[email protected]] On Behalf Of Pete Appleton Sent: 26 February 2013 13:42 To: [email protected] Subject: [nhusers] Controlling cascade order Firstly, my apologies for the HTML mail with a picture - I hope this doesn't cause too much offence, but I wasn't able to articulate the issue without resorting to graphics. The picture below shows a simplified object graph that we're trying to update in a single transaction. Our handle onto the graph is a new (transient) instance of entity [C] - everything in the graph is new except for the [QB] entity which is existing. All collections are marked as cascade style all-delete-orphan, and the one-to-one association from [C] to [A] is marked as a save-update as is the many-to-one from [S] to [QB]. The association from [A] to [C] is not marked with any cascade annotation. When we attempt to persist this graph we get a transient object exception relating to [Q] at the point where NHibernate attempts to persist the new instance(s) of [P] because NHibernate has yet to traverse the [C] -> [A] association; if we omit the [P] -> [Q] link by setting the mapped property to null and temporarily permitting nulls then the DB operation is successful. Clearly, for this operation to succeed the new [Q] instances must be persisted prior to anything else because the top-level entities depend upon them. How can we ensure that this happens please? Thanks in advance, /Pete !DSPAM:1,512cbbf81876678915753! -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/nhusers?hl=en. For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/nhusers?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
<<image001.png>>
