David I'm not certain that I'm understanding your issue correctly, but
if I am then the solution is straightforward...

You want another object (lets call it MyFunctionDescription) to have a
reference to an object of type "parameter".  But it won't actually be
of type parameter, it will be one of "parameter"'s subtypes

Solution:  Use one of the NHibernate inheritance mapping strategies
(described in the reference manual) and NHibernate will take care of
all the work making sure it tracks the subtype of the object you've
saved.  You don't map it to the subtypes tables yourself, its
automatic.  Simply create a property of type "parameter", and then
you'll be able to set it to any of the subtypes in your application
code.  Your NHibernate mapping XML declares the property of
"parameter" as well.

<MyFunctionDescription.cs>
public class MyFunctionDescription {
    ...
    public parameter myParameter { <getter/setter> }
    ...
}

and the XML:
<class name="MyFunctionDescription">
    ...
    <many-to-one name="myParameter" type="parameter"
colum="parameter_id" ...

Is this helpful?


Best, Brian

On Mar 16, 9:58 am, David Laabs <[email protected]> wrote:
> I habe a list of objects that are all inherited from a common
> baseclass.
>
> Baseclass ist "parameter" and is a real entity (with own table) but is
> abstract. My parameters (like "languagte", "titletype", "texttype",
> "picturetype",...) are all inherited from "parameter" and some of them
> have own tables (join-subclass) othes haven't (subclass).
>
> Now I habe an object that schould have a many-to-one relation property
> to an existing "parameter" of one of the inherited types... for
> example "language". But it can be any of the existing parameters in
> the system. I want to bind the property to the baseclass only.
>
> How can I tell NHibernate that I want to have a relation to the PK
> (ID) of "parameter"? Of course the column in my entity will call
> "paraemter_id", but I also want to have a foreign-key constraint to
> the "parameter"-table.
>
> Thanks for any help. :-)

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