-->
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.  [ 4 posts ] 
Author Message
 Post subject: Mapping of legacy DB, table per class hierarchy
PostPosted: Tue Jan 27, 2009 7:06 am 
Newbie

Joined: Tue Jan 27, 2009 6:42 am
Posts: 7
Hello,

I'm mapping a legacy DB in hibernate and I have the following problem:

I have a parent class A and two subclasses B and C. This mapping looks as follows and works fine:


Code:
<class name="A" table="TABLE_A">
               
   <joined-subclass name="B" table="TABLE_B">
               
   </joined-subclass>
   
   <joined-subclass name="C" table="TABLE_C">
         
   </joined-subclass>
       
</class>




The problem is, that TABLE_B contains a table-per-class-hierachy, that means Class B is also a parent class of two subclasses D and E. The Values D and E are stored in TABLE_B, distinguished by a discriminator-column.


I tried to make a mappingfile like this:

Code:
<class name="A" table="TABLE_A">
               
   <joined-subclass name="B" table="TABLE_B">
      
      <discriminator column="DISCR" type="string" />
      
      <subclass name="D" discriminator-value="D"></subclass>
      <subclass name="E" discriminator-value="E"></subclass>
      
   </joined-subclass>
   
   <joined-subclass name="C" table="TABLE_C">
         
   </joined-subclass>
       
</class>


Whit this mapping I get an validationerror which tells me, that the content of <joined-subclass/> is not well formed.

Can anyone please tell me, how to make this work.

Thank you in advance,
Rudi
Code:


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2009 3:44 am 
Newbie

Joined: Tue Jan 27, 2009 6:42 am
Posts: 7
Hello,

has anybody an idea on this problem? It's still important for me.

thank you,
Rudi


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2009 4:11 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
I don't think this is possible. From the docs at http://www.hibernate.org/hib_docs/v3/re ... tance.html

Quote:
Hibernate does not support mixing <subclass>, and <joined-subclass> and <union-subclass> mappings under the same root <class> element


There seems to be some support for mixing <subclass> and <join> but all the examples assume that the discriminator column is in the root table.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2009 12:56 pm 
Newbie

Joined: Tue Jan 27, 2009 6:42 am
Posts: 7
Hi nordborg,

thank you for your reply. It's a pity that's not possible but at least now I don't search for a solution anymore ;)

best regards,
Rudi


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