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 ?