-->
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: Table per class hierarchy
PostPosted: Mon Sep 01, 2008 2:13 am 
Regular
Regular

Joined: Tue Dec 14, 2004 5:21 am
Posts: 104
Location: india
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.2.6 GA

i have a class hierarchy that looks like this :

abstract class vehicle {}

class bike extends vehicle {}

abstract class car extends vehicle {}

class sedan extends car{}

class suv extends car {}


i am doing a Table per class hierarchy mapping with following discriminator values on "type" column

bike - 1
sedan - 2
suv - 3

"car" doesnt have a discriminator value

here is the mapping i have .

Code:
<class name = "vehicle" table="vehicle">

<discriminator formula="(SELECT CASE
           WHEN v.type= "bike"
              THEN 1
           WHEN v.type= "sedan"
              THEN 2
           WHEN v.type= "suv"
              THEN 3
        END FROM vehicle v")/>

<subclass name="bike" discriminator-value="1">
</subclass>

<subclass name="car">

   <subclass name="sedan" discriminator-value="2">
   </subclass>

   <subclass name="suv" discriminator-value="3">
   </subclass>

</subclass>

</class>



the class hierarchy cannot be changed since it belongs to a legacy code. my problem is, given such a mapping , sedan and suv are not getting loaded.
i suspect subclass car not having a discriminator value as the cause.
how do i resolve this? is there anything wrong with the mapping ?

_________________
sHeRiN
thanks for your ratings ...... :)


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.