-->
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: Problems with inheritance mapping
PostPosted: Mon Nov 26, 2007 9:11 am 
Newbie

Joined: Mon Nov 26, 2007 7:59 am
Posts: 1
Hi,

I'm trying to implement a simple class inheritance mapping. I have one parent class and two subclasses which are mapped by the table per subclass strategy. The mapping looks like the following:
Code:
<hibernate-mapping>
   <class name="Parent" table="Parent">
      <id name="PID" type="java.lang.Integer">
               <column name="PID"/>
         <generator class="increment" />
      </id>
        <property name="description" column="description" type="java.lang.String" />
                <one-to-one name="location" class="Location" column="location"/>

      <joined-subclass name="Male" table="Male">
       <key column="PID"/>
       <one-to-one name="Female" class="Female" column="female"/>
      </joined-subclass>

      <joined-subclass name="Female" table="Female">
       <key column="PID"/>
       <one-to-one name="Male" class="Male" column="male"/>
      </joined-subclass>
    </class>
</hibernate-mapping>


I have filled the database with some test data.
    9 entries in the parent table (PID from 1 to 9)
    3 entries in the male table (PID 1,3,7)
    6 entries in the female table (PID 2,4,5,6,8,9)

Now I'm trying to read the property location from a given Parent object. I use getLocation(). But then Hibernate throws the following HibernateException:
Code:
org.hibernate.HibernateException: More than one row with the given identifier was found: 9, for class: Parent


Well, I can't figure out why Hibernate complains about this particular entry, but not about other entries.

Should I use another mapping strategy? Or am I missing something important?

Thanks,
Tino


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.