You just gave yourself the solution. That is exactly what you have to do, set all references to the object you are deleting to null (from otther persistent objects, of course) And that is not really a NH constraint but more a consistency constraint of the code in general. First of all you have to work correctly with your objects that is, in your example, when you no longer need a child "WebpageMetaDataMap" you clean its parent first (instance of the Webpage) by setting it to null or maybe asigning another instace of Webpage. Then in case you are working with persistent objects you can delete them manually or let NH do that for you automatically by setting the cascading to all-delete-orphan (I would do that in your example). The error you get from NH is quite self explanatory, the Webpage.WebpageMetaData property untill set to null still has a value and the cascading that you defined for the property tells NH to save it to DB as soon as the session is flushed.
On Jan 9, 6:03 pm, J3ffb <[email protected]> wrote: > Hi, > > I have run into an issue when deleting an entity in a one-to-one > relationship using cascade. I get an exception stating "deleted > object would be re-saved by cascade (remove deleted object from > associations)". The only way to supress this is to visit the > otherside of the relationship and set the reference back to yourself > to null. > > So not to repeat myself I will give you a link to my StackOverflow > post, where someone suggested posting on this list to see if you guys > could help out. > > http://stackoverflow.com/questions/1996860/cascade-issue-when-deletin... > > I am using Fluent, but I have added the xml mappings to the end of the > post. > > Thanks for any help :)
-- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
