Sorry just a minute or two after I wrote this I figured it out. Here is what I did wrong:
First, on my mapping I did not specify that it was an inverse, I got that little nugget of information from here: http://gregdoesit.com/2009/01/deleting-a-one-to-many-relationship-in-nhibernate/ Second, on my mapping I had cascade="all" but I really should have done cascade="all-delete-orphan". Doing this produced exactly the results I was looking for. Hope this helps someone. Thanks, Josh On Jun 18, 12:42 pm, joshlrogers <[email protected]> wrote: > I have a class/table that has a collection(IList) of details. I am > trying to get NHibernate to delete these details when I remove them > from the collection. > > So...simply I am trying to do this... > > 1. Clear (.Clear()) or Remove (.Remove(JobDetail)) from the class > 2. Call Update on the class to update the table and remove the child > (ren) that have been removed from the collection > > This is resulting in this error: > > could not delete collection: [TEAMS_ORM.Job.JobDetails#30010][SQL: > UPDATE dbo.tblJobDetails SET JobID = null WHERE JobID = @p0] > > So it is trying to set the JobID(the relational id) to null rather > than deleting these items. > > I do have cascade="all" although I don't believe that has any bearing > on this situation as I am not deleting the parent just the children. > > I would prefer not to remove these explicitly so is there some method > that I am overlooking for achieving my desired result? > > Thank you for your help in advance. > Josh --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
