on-delete="cascade"

2008/11/26 Graham Bunce <[EMAIL PROTECTED]>

>
> Hi,
>
> I'm looking to ways of improving performance in NHibernate and came
> across this in the documentation:
>
> 16.5.4. One shot delete
>
> Occasionally, deleting collection elements one by one can be extremely
> inefficient. NHibernate isn't completely stupid, so it knows not to do
> that in the case of an newly-empty collection (if you called list.Clear
> (), for example). In this case, NHibernate will issue a single DELETE
> and we are done!
>
> I'm not sure how to ensure this works as in my tests NHibernate never
> does this e.g. If newContent is an object with a collection of Assets
> and I want to delete the Content, I do this:
>
> Session.Delete(content).
>
> Assuming my mapping file is set to cascade="delete" the related assets
> will get deleted, but line by line, i.e. based on their unique id, not
> the fact that all have a contentId (SQL would be delete from Asset
> where contentid = ?)
>
> If I do a content.Assets.Clear(), from the above, I would expect
> NHibernate to be really clever and do a one-shot delete.... but it
> doesn't. In fact it crashes with a database referential integrity
> error as no deletes for assets ever get submitted, presumably because
> I've cleared the collection.
>
> What am I doing wrong?
> >
>


-- 
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to