-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Multiple joined-subclass loads wrong entity
PostPosted: Fri Apr 01, 2011 10:24 am 
Newbie

Joined: Fri Apr 01, 2011 9:21 am
Posts: 1
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 :-)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.