I also understand delete-orphans in the context of collections. The
example in the reference is quite good (seems to be down at the
moment).

If you were to have a collection of Addresses in the City (nonsensical
but just to keep using your domain), by using all-delete-orphans in
the collection you could delete an Address by simply removing it from
the collection. Using cascade=all you would have to explicitly delete
the Address after removing it from the collection.

That is how I understand delete-orphans. I'm not sure what it means in
the case of many-to-one associations, but I don't think it will delete
your 'last city'.

On Oct 2, 9:16 pm, Igor <[email protected]> wrote:
> I always think that cascade="delete-orphan" apply ONLY to collection
> associations (one-to-many in a set or bag) - not to many-to-one
> association.
> And probably there is NO way for nHibernate to know that there are
> some other references to this city - from another Address object or
> from object of totally different class... At least if they are not
> loaded in session.
> nHibernate work "in memory" - it doesn't know about any DB
> constraints, triggers or other stuff. And it doesn't put a piece of
> code to DB side to track something.
> You can't "delete" City every time a single reference to it is
> destroyed - the opposite cascade may exist (if you'll have bag/set in
> City class references all Addresses belong to this city) -
> cascade="all" will delete a City and all its Addresses if you delete
> City, but not vise-versa.

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