-->
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.  [ 3 posts ] 
Author Message
 Post subject: inheritance with per class hierarchy
PostPosted: Tue Jun 06, 2006 4:25 pm 
Beginner
Beginner

Joined: Fri Mar 12, 2004 1:02 pm
Posts: 23
Hi,

I was wondering how to do a simple per-class-hierarchy mapping for an object graph 3 levels deep. For example, say I want to map the abstract base classes X <-- Y <-- Z. I assumed you can nest the <subclass> element in order to achieve this but I'm not getting the result I want when hibernate generates the schema. Here is my map:



Code:
<class name="X" table="X">
    <id name="id" type="long" column="X_ID">
        <generator class="native"/>
    </id>
    <discriminator column="X_TYPE" type="string"/>
    ...
    <subclass name="Y">
         <subclass name="Z">

         </subclass>
        ...
    </subclass>
</class>



I would assume this is the correct way but I know it is not since I'm not getting the schema generated accordingly (Y and Z are linked to X). Any help would be appreciated. Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 07, 2006 9:33 am 
Beginner
Beginner

Joined: Fri Mar 12, 2004 1:02 pm
Posts: 23
Hi,

I've been trying to get more than 2 levels of this inheritance working but it seems that the way the hibernate mapping is structured, you can not define a subclass of a subclass within the same class element--i.e. X <-- Y <-- Z is not possible, only X <-- Y and X <-- Z (only 2 levels deep). I tried a similar mapping using mixed inheritance--per-class hierarchy and per-subclass-- but I still could not get it to work... see my other post for code example:
http://forum.hibernate.org/viewtopic.ph ... highlight=

Looks like I'll have to try something else or keep everything flat...

-los


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 20, 2006 3:31 pm 
Beginner
Beginner

Joined: Thu Jul 20, 2006 12:08 pm
Posts: 21
Location: Germany
moraleslos wrote:
Hi,

I've been trying to get more than 2 levels of this inheritance working but it seems that the way the hibernate mapping is structured, you can not define a subclass of a subclass within the same class element--i.e. X <-- Y <-- Z is not possible, only X <-- Y and X <-- Z (only 2 levels deep). I tried a similar mapping using mixed inheritance--per-class hierarchy and per-subclass-- but I still could not get it to work... see my other post for code example:
http://forum.hibernate.org/viewtopic.ph ... highlight=

Looks like I'll have to try something else or keep everything flat...

-los


Hi,

why don't you create a mix of table per class hierarchy and table per subclass ?

regards


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.