I just looked and here is the full cascade dictionary for NH 2.1 GA:
static CascadeStyle()
{
        Styles["all"] = All;
        Styles["all-delete-orphan"] = AllDeleteOrphan;
        Styles["save-update"] = Update;
        Styles["persist"] = Persist;
        Styles["merge"] = Merge;
        Styles["lock"] = Lock;
        Styles["refresh"] = Refresh;
        Styles["replicate"] = Replicate;
        Styles["evict"] = Evict;
        Styles["delete"] = Delete;
        Styles["remove"] = Delete; // adds remove as a sort-of alias for 
delete...
        Styles["delete-orphan"] = DeleteOrphan;
        Styles["none"] = None;
}

Sure enough, "delete-orphan" is there, and it has a valid CascadeStyle
implementation:
[Serializable]
private class DeleteOrphanCascadeStyle : CascadeStyle
{
        public override bool DoCascade(CascadingAction action)
        {
                return action == CascadingAction.Delete || action ==
CascadingAction.SaveUpdate;
        }

        public override bool ReallyDoCascade(CascadingAction action)
        {
                return action == CascadingAction.Delete;
        }

        public override bool HasOrphanDelete
        {
                get { return true; }
        }
}

The question is now what to do about it. :)

On Fri, Sep 4, 2009 at 12:22 PM, Stuart Childs<[email protected]> wrote:
> Well, looking back as far as the 1.0.2 documentation, only the
> following cascades are documented:
>
> cascade="all|none|save-update|delete|all-delete-orphan"
>
> I also found this comment from January 14: "Hmm.. I'm using NHibernate
> 2.2 and this happens: [MappingException: Unsupported cascade style:
> delete-orphans]"
> (here: 
> http://stackoverflow.com/questions/444753/how-do-i-make-nhibernate-delete-child-refererences-when-i-delete-a-parent)
>
> Now I suppose it's possible that they slipped in a delete-orphans
> cascade and didn't tell anyone but I'd have to check the NH source to
> find out.
>
> On Fri, Sep 4, 2009 at 10:05 AM, James Crowley<[email protected]> wrote:
>>
>> Hmm, I'm even more confused now!
>>
>> Ayende makes reference to this way back in 2006:
>>
>> http://ayende.com/Blog/archive/2006/12/02/NHibernateCascadesTheDifferentBetweenAllAlldeleteorphansAndSaveupdate.aspx
>>
>> ??
>>
>> Thanks
>>
>> James
>>
>> 2009/9/4 Hudson Akridge <[email protected]>:
>>> Mike is correct
>>>
>>> On Fri, Sep 4, 2009 at 5:33 AM, Mikael Henriksson <[email protected]>
>>> wrote:
>>>>
>>>> As far as the NHibernate reference is concerned there is no cascade
>>>> "delete-all-orphans" maybe cascade "delete" is the one you are
>>>> after? Cascade.Delete() in fluent. If it's not supported in nhibernate it's
>>>> not going to be supported in Fluent either.
>>>>
>>>> On Fri, Sep 4, 2009 at 10:07 AM, James Crowley <[email protected]>
>>>> wrote:
>>>>>
>>>>> Hi Mikael,
>>>>>
>>>>> thanks for the response. Unfortunately, that's the "all-delete-orphan"
>>>>> option (which I'd normally use), but I need the "delete-orphan" option
>>>>> (so it doesn't automatically persist inserts and updates). I'm having
>>>>> to do a slightly nasty workaround as described here:
>>>>>
>>>>> http://fgheysels.blogspot.com/2009/05/forcing-nhibernate-to-cascade-deletes.html
>>>>>
>>>>> in order to be able to delete and then insert entities on a collection
>>>>> with a unique constraint (that's not on its primary key).
>>>>>
>>>>> Unless you have any suggestions on how else I might achieve this?
>>>>>
>>>>> Many thanks,
>>>>>
>>>>> James
>>>>>
>>>>> 2009/9/3 Mikael Henriksson <[email protected]>:
>>>>> > .I believe what you are looking for is Cascade.AllDeleteOrphan()
>>>>> >
>>>>> > On Thu, Sep 3, 2009 at 11:10 PM, James Crowley
>>>>> > <[email protected]>
>>>>> > wrote:
>>>>> >>
>>>>> >> I'm probably missing something blindingly obvious here, but is there
>>>>> >> any reason why there is no delete-orphan option when setting the
>>>>> >> cascade types?
>>>>> >>
>>>>> >> Thanks
>>>>> >>
>>>>> >> James
>>>>> >>
>>>>> >>
>>>>> >
>>>>> >
>>>>> > >
>>>>> >
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> James Crowley
>>>>> Managing Director
>>>>> Developer Fusion - Connecting developers worldwide
>>>>>
>>>>> Developer Fusion Ltd | 58 Sandringham Close | Enfield, EN1 3JH
>>>>> mob: 07986 624128 web: http://www.developerfusion.com/
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> - Hudson
>>> http://www.bestguesstheory.com
>>> http://twitter.com/HudsonAkridge
>>>
>>> >
>>>
>>
>>
>>
>> --
>> James Crowley
>> Managing Director
>> Developer Fusion - Connecting developers worldwide
>>
>> Developer Fusion Ltd | 58 Sandringham Close | Enfield, EN1 3JH
>> mob: 07986 624128 web: http://www.developerfusion.com/
>>
>> >>
>>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" 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/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to