-->
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: question on table-per-class-hierarchy mapping strategy
PostPosted: Fri Feb 16, 2007 12:08 pm 
Newbie

Joined: Fri Feb 16, 2007 11:12 am
Posts: 1
I am using the table-per-class-hierarchy mapping strategy to persist an entire class hierarchy into a singe table. I understand I can map a single subclass in this hierarchy to a separate table using the <join> mapping element. Is there a way, however, to persist an entire branch or subtree of this class hierarchy rooted at a given subclass to a seperate table?

Consider this simple example. Suppose we have four classes:

D extends C extends B extends A

I want to map A and B to one table and C and D to another table, with the latter having a foreign key into the former, using something like:

<hibernate-mapping>
<class name="A" table="rootTable" discriminator-value="A">
...
<subclass name="B" discriminator-value="B">
...
<subclass name="C" discriminator-value="C">
<join table="childTable">
...
<subclass name="D" discriminator-value="D">
...
</subclass>
</join>
</subclass>
<subclass>
</class>
</hibernate-mapping>

But the DTD for hibernate.hbm.xml does not allow nesting <subclass> elements under a <join> element! I can get around this problem by moving the <subclass> element for D ouside the enclosing <join> and adding the appropriate "extends" attribute, but that causes D to be persisted in the rootTable, not the childTable.

Is there another way to achieve what I want?

Any help/pointers/suggestions will be be greatly appreciated.

I am using Hibernate 3.2.

Thanks in advance.

-- Hira.


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.