Hi,
Relatively new to NHibernate, but got small mapping problem:
I have 3 tables in my database: Person, User and Membership
Person is the base-person content, User is used when a Person is granted login rights and Membership is used when a Person has membership rights (not the same as User rights).
In the code I have an abstract PersonBase-class. I also have a User-class and a Membership-class that both inherits the PersonBase-class. This is a part of my mapping file (I only have one mapping file for the three classes):
Code:
<class name="PersonBase" table="Person" lazy="false">
<id name="PersonBaseId" type="Int32" unsaved-value="0" column="Id">
<generator class="native" />
</id>
...
<property name="Name" column="Name" type="String" length="70" not-null="true" />
...
<joined-subclass name="User" table="User">
<key column="PersonId" unique="true" />
<property name="StatusCode" column="StatusCodeId" type="StatusCode" not-null="true" />
</joined-subclass>
<joined-subclass name="Membership" table="Membership">
<key column="PersonId" unique="true" />
</joined-subclass>
I am using SessionInView as session-policy (it is a webapplication).
I have a seperate DAO class for both the User- and the Membership-class.
My problem is:
If a Person both have User-registration and Membership-registration and I use GetById on the Membership class, NHibernate loads the User-class and throws an error about wrong type loaded. I tried to switch places for the to <joined-subclass> statements - this only provided the "reverse" problem (using GetById on the User-class loads a Membership-class).
Any ideas on why NHibernate won't load the correct class?
Thanks in advance for any help on this subject :-)