-->
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.  [ 2 posts ] 
Author Message
 Post subject: subclass and entity-name
PostPosted: Sun Oct 28, 2007 10:51 am 
Newbie

Joined: Fri Sep 15, 2006 6:07 am
Posts: 5
Hi all,
I am using Hibernate 3.1 and I am facing a problem mapping object hierarchy to different tables.

I have the class hierarchy:
Code:
abstract class Criterion {}
class StringCriterion extends Criterion {}
class StatusCriterion extends Criterion {} 

I have an appropriate mapping file:
Code:
<hibernate-mapping package="com.criterion" default-access="field">
   <class name="Criterion" table="CRIT_T" abstract="true" discriminator-value="999">
               
                ....
               
      <discriminator column="ELMNT_TYPE" type="long"/>
       <subclass name="StatusCriterion" discriminator-value="1" >
         <property name="alarmStatus" column="ELMNT_FIRST_VALUE"
         type="string"/>
      </subclass>
      <subclass name="StringCriterion" discriminator-value="2" >
         <property name="value" column="ELMNT_FIRST_VALUE" type="string"/>
      </subclass>
   </class>
</hibernate-mapping>


This mapping works great, but when I tried to map these classes to different tables (by adding an entity-name attribute to the subclass and class elements in the hbm file) I failed.
I am quite familiar with the entity-name attribute and it is not the first time I am using it, but this time it "combined" with sub classing.
Is there any known bug on that? Or I am simply wrong?

Thanks in advance.
Guy


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 02, 2007 10:00 pm 
Newbie

Joined: Tue Sep 04, 2007 2:21 pm
Posts: 14
Check the hibernate reference docs. for "a table per subclass mapping" the primary subclass xml tag is joined-subclass not subclass.

HTH
Tom


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

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.