I think I misread your initial email as I went looking for a way to do this
with conventions without actually checking to see if the fluent interface
supports it. I've done a little more investigation and now I suspect it is
not possible to set a key-many-to-one as cascade, because the nhibernate
mapping schema does not support it:

    <xs:element name="key-many-to-one">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="meta" minOccurs="0" maxOccurs="unbounded"
/>
                <xs:element ref="column" minOccurs="0" maxOccurs="unbounded"
/>
            </xs:sequence>
            <xs:attribute name="name" use="required" type="xs:string" />
            <xs:attribute name="access" type="xs:string" />
            <xs:attribute name="class" type="xs:string" />
            <xs:attribute name="entity-name" type="xs:string" />
            <xs:attribute name="column" type="xs:string" />
            <xs:attribute name="foreign-key" type="xs:string" />
            <xs:attribute name="lazy" type="restrictedLaziness">
            </xs:attribute>
        </xs:complexType>
    </xs:element>

As you can see, there is no cascade attribute.

On Sat, Oct 24, 2009 at 11:24 PM, Mohamed Meligy <eng.mel...@gmail.com>wrote:

> So, do you suggest some workaround or so?
>
>
> Regards,
>
> --
> Mohamed Meligy
> Information Analyst (.Net Technologies) – Applications Delivery - TDG
> Injazat Data Systems
> P.O. Box: 8230 Abu Dhabi, UAE.
>
> Phone:  +971 2 6992700
> Direct:   +971 2 4045385
> Mobile:  +971 50 2623624
>
> E-mail: eng.mel...@gmail.com
> Weblog: http://weblogs.asp.net/meligy
>
>
> On Sat, Oct 24, 2009 at 9:17 AM, Paul Batum <paul.ba...@gmail.com> wrote:
>
>> FNH currently does not support conventions on key-many-to-one mappings. It
>> probably wouldn't be that hard to implement, as the inspector interface is
>> already there for them (its IKeyManyToOneInspector), but the instance
>> interface for actually modifying the mapping doesn't yet exist (it would be
>> called IKeyManyToOneInstance).
>>
>>
>> On Tue, Oct 20, 2009 at 4:41 AM, Mohamed Meligy <eng.mel...@gmail.com>wrote:
>>
>>> First,  I know what I'm going is most likely not supported. I just want
>>> to make sure, and question if there's some workaround.
>>>
>>> The question in brief is: If I have an entity with CompositeId, one part
>>> of this Composition is a Reference to another entity.
>>> If I map this Reference using "CompositeId" function of ClassMap
>>> "CompositeId().KeyReference(...)", how can I set the Cascade model of the
>>> referenced entity?
>>>
>>> I know for a non CompositeIdPart, it's easy:
>>>
>>> References(x => x.SomeReferencedObjectProperty).Cascade.All();
>>>
>>> But if the entity was mapped in a way similar to:
>>>
>>> CompositeId()
>>>     .KeyProperty(x => x.SomeProperty)
>>>
>>>
>>>
>>>     .KeyReference(x => x.SomeReferencedObjectProperty);
>>>
>>> How can I set the cascade of "SomeReferencedObjectProperty"?
>>>
>>> I tried some workaround that I described here
>>> http://stackoverflow.com/questions/1420498/how-to-cascade-save-with-compositeid-in-nhibernate/1584335#1584335
>>> but this way when I generate the schema and execute NH queries, etc, I
>>> find two  columns created (see the link for more details).
>>>
>>> Although I think this case above is very basic and sure happens a lot if
>>> I decide to map also Many-To-Many middle tables, so, it's really weird that
>>> I can't get it straight forward. I'm new to NH in geenral anyway!
>>>
>>> If you are wondering why I need to do this, here is my specific case
>>> (changed names of the models for confidentiality): I'm working on an
>>> existing site that is like a document mnagement tool. Each document has its
>>> contents and the user that submitted the document, plus some other details.
>>> The entore website data layer is built using SPROCs and some helpers, and
>>> manual mapping of result sets to POCO classes, which are act as just DTOs
>>> between the UI/BLL and Data Access.
>>> Now, part of my task was to modify the website to implement something
>>> like MasterPage for documents. Each user will browser the master pages, and
>>> choose to apply the master page to one of the documents he uploaded already.
>>> This means there is a Many-To-Many relation between "MasterPage" and
>>> "Document". I want to do this without affecting any part of the "Document"
>>> UI layer, for a simple reason - it just works! No errors or such were found
>>> and users are happy with it, so, no reason to re-implment those.
>>> So, I though, I'll model my "MasterPage" using FNH, and have something
>>> like "DocumentMasterPage", which includes reference to "MasterPage" and INT
>>> DocumentId referencing the "Document" PK. Of course I could also make my own
>>> "Document" model and map Many-To-Many between "Document" and "MasterPage"
>>> without modeling middle tables, but it sounded ugly to duplicate something
>>> that already exists ("Document").
>>>
>>>
>>> I know that was too much talk, so, again, my main question is:
>>> *If I map this Reference using "CompositeId" function of ClassMap
>>> "CompositeId().KeyReference(...)", how can I set the Cascade model of the
>>> referenced entity?*
>>>
>>>
>>> Thank you,
>>>
>>> Regards,
>>>
>>> --
>>> Mohamed Meligy
>>> Information Analyst (.Net Technologies) – Applications Delivery - TDG
>>> Injazat Data Systems
>>> P.O. Box: 8230 Abu Dhabi, UAE.
>>>
>>> Phone:  +971 2 6992700
>>> Direct:   +971 2 4045385
>>> Mobile:  +971 50 2623624
>>>
>>> E-mail: eng.mel...@gmail.com
>>> Weblog: http://weblogs.asp.net/meligy
>>>
>>>
>>>
>>
>>
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to