Hi Oskar,
Thanks for your input. Yeah I took the delete orphan thing off.
I'm now begining to think of remodelling the relationship altogether.
Thinking about it, it's actually more of a one-to-many so if I remodel
it in the DB
that each advert row just has a FK reference to it's parent I can then
use all-delete-orphan if I choose.

Although all-delete-orphan does complicate things in terms of using
automapper etc. so I might let the DB manage via cascade.

cheers.

On Jan 3, 4:00 pm, Oskar Berggren <[email protected]> wrote:
> all-delete-orphan is a tool used with one-to-many, since that type of
> relationship often indicate that the children's lifecycle are
> controlled by the parent. In many-to-many, one cannot say that one
> side owns the other side. I'm not sure if all-delete-orphan will do
> anything at all for many-to-many, but if anything it will look at the
> loaded collection. It is not a tool to conduct various queries in
> order to find unreferenced entities in the database.
>
> /Oskar
>
> 2011/12/29 Davec <[email protected]>:
>
>
>
>
>
>
>
> > Hi all, happy new yr.
>
> > I'm wonder is all-delete-orphan cascade option implemented for many to
> > many collections in NH 3.2.
> > I can't seem to get it working, but I did think I had it working a
> > couple of weeks ago. I have got the
>
> > 'Don't dereference a collection with cascade="all-delete-orphan"
>
> > error recently which meant I had to do a clear() and then add back one
> > by one. However I'd rather not have to do this if all-delete-orphan
> > isn't even implemented as it mucks up my automapper/memberwiseclone
> > code. The docs mention one-many but don't explicitly say that it
> > doesnt work for many-to-many collections. But a couple of hiberate
> > related threads say that for many-to-many delete-orphan is not
> > implemented.
>
> > I have
>
> > <bag name="PreRollAdverts" table="Level1Advert" cascade="all-delete-
> > orphan">
> >                <key column="Level1ID"></key>
> >                <many-to-many class="AVMS.Domain.Entities.Advert"
> > column="AdvertID"></many-to-many>
> > </bag>
>
> > and on a different level/
>
> > <bag name="PreRollAdverts" table="Level2Advert" cascade="all-delete-
> > orphan">
> >                <key column="Level2ID"></key>
> >                <many-to-many class="AVMS.Domain.Entities.Advert"
> > column="AdvertID"></many-to-many>
> > </bag>
>
> > Is it a long shot that if I remove ad X from the either of the
> > collections, that nibernate query both many to many tables,
> > level1advert and level2advert to see if X is still referenced, and if
> > not delete X from the Advert table itself?
>
> > How would I manage this in the DB? Ref intreg wouldn't work because
> > there are two many to many tables so I'm guessing a trigger?
>
> > Thanks in advance.
>
> > --
> > 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 
> > athttp://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.

Reply via email to