-->
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: Multiple discriminator columns
PostPosted: Tue Oct 18, 2011 4:51 am 
Newbie

Joined: Tue Oct 18, 2011 2:56 am
Posts: 2
I have similar problem mentioned in the below link. Kinldy help me to get a solution for the same. The question is about how to specifiy multiple discriminator columns in a single table inheritance statergy (multilevel inheritance).

viewtopic.php?f=9&t=963341


Top
 Profile  
 
 Post subject: Re: Multiple discriminator columns
PostPosted: Fri Oct 21, 2011 8:57 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
I absolutely don't understand the necessity of having Multiple discriminator columns.
Each entity record in the database must be unambiguously assignable to a concrete class.
The discriminator column is the holder of this information when you use single table inheritance strategy.
Java does not support multiple class inheritance, so why do you want map multilevel inheritance?


Top
 Profile  
 
 Post subject: Re: Multiple discriminator columns
PostPosted: Mon Nov 21, 2011 12:50 am 
Newbie

Joined: Mon Nov 21, 2011 12:40 am
Posts: 1
It's not to support multiple inheritance (i.e. a class with two parents) it's to support multi-level inheritance. Multi-level is fairly intuitive when using table-per-subclass, but not when it comes to table-per-hierarchy.

Say my class hierarchy is the following, and I want to use table-per-hierarchy:

Cat
--DomesticCat
-----Persian
-----Manx
--WildCat
-----Tiger
-----Lion

What I'd like to do is create the table CAT with discriminator columns TYPE and SUB_TYPE.

TYPE can have the values "DOMESTIC" and "WILD".
SUB_TYPE can have the values "PERSIAN", "MANX", "LION" and "TIGER".

The mapping would look something like:

Code:
<class name="Cat">
   <discriminator column="TYPE">
   <subclass name="DomesticCat" discriminator-value="DOMESTIC">
       <discriminator column="SUB_TYPE">
       <subclass name="Persian" discriminator-value="PERSIAN"/>
       <subclass name="Manx" discriminator-value="MANX"/>
   </subclass>
   <subclass name="WildCat" discriminator-value="WILD">
       <discriminator column="SUB_TYPE">
       <subclass name="Tiger" discriminator-value="TIGER"/>
       <subclass name="Lion" discriminator-value="LION"/>
   </subclass>
</class>


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.