what mean cascade="none" + on-delete="cascade" ? 2008/11/27 Graham Bunce <[EMAIL PROTECTED]>
> > Ok.. well that doesn't work either. Mapping is as follows: > > <?xml version="1.0" encoding="utf-8" ?> > <hibernate-mapping > xmlns="urn:nhibernate-mapping-2.2" > namespace="Domain.SupplyChain" > assembly="Domain.SupplyChain" > default-access="field.camelcase-underscore" > default-lazy="true"> > <class name="Asset" > proxy="Domain.SupplyChain.Interfaces.IAsset, > Domain.SupplyChain.Interfaces" > table="Asset"> > <id name="Id" column="Id" unsaved- > value="00000000-0000-0000-0000-000000000000" access="property"> > <generator class="guid.comb" /> > </id> > <property name="Name" type="string" length="255" not-null="true" / > > > <bag name="AssetContents" table="AssetContents" inverse="true" > cascade="none" > > <key column="AssetId" on-delete="cascade" /> > <one-to-many class="AssetContent" /> > </bag> > </class> > </hibernate-mapping> > > I've tried it with cascade="delete" at bag level at the same time as > well, no difference. > > My code is something like: > > content.Assets.Clear(); > session.Delete(content); > > This caused a database RI crash, so I just tried "session.Delete > (content);" which deleted each AssetContent line by line as opposed to > "delete from AssetContent where contentid = ?". > > Now, digging around on the internet for what on-delete="cascade" > actually means I came across an article that suggested it means > NHibernate leaves deletes of collections to the database, i.e. I need > to change the database RI to be ON_DELETE CASCADE. This is ok in my > scenario (its a new database) but now I have rules in my DB and in my > domain. > > However, if I do have ON_DELETE CASCADE then I can change my map to > have on-delete="cascade" or not to have it and and long as I use a > list.Clear() method then it actually makes no difference at all, as > I'm using the DB to do the delete and not HNibernate. If I don't have > a list.Clear() then no matter what the map setting is (with or without > cascade) NHibernate will submit several deletes as opposed to one. > > I really can't work out how to do what I want (single shot delete) in > NHibernate without changing my database RI. > > I'm using NHIbernate 2.0.1GA > > > > > > -- Fabio Maulo --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
