First you say it's many-to-many. Then you say what when one side is deleted, the other should be deleted too, which is weird in many-to-many since there could be other references.
In Customer you indeed have a many-to-many mapping, but in Contact you have a many-to-one mapping back to Customer. Why? And you have the relation table CustomerContact, and yet the Contact also has a direct reference to Customer. Why? I think you need to confirm if this really is many-to-many or many-to-one. /Oskar 2011/8/27 Kris-I <[email protected]>: > Hello, > > I have a object Customer, this object has an ISet list of Contact. > When I delete a Customer I'd like to delete the Contact. > > I use the mapping below, I tried all option in cascade but still have > this problem : The DELETE statement conflicted with the REFERENCE > constraint "FK4FF8F4B29499D0A4". The conflict occurred in database > "MyDB", table "dbo.Contact", column 'Customer'. > > The mapping "Customer" : > > <set name="Contacts" table="CustomerContact" cascade="save-update"> > <key column="Customer" /> > <many-to-many class="Contact" column="Contact" /> > </set> > > The mapping "Contact" : > > <many-to-one name="Customer" column="Customer" not-null="true" /> > > Any idea ? > > Thanks, > > -- > 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. > > -- 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.
