Hi,
hopefully this is straight forward to somebody, and I'm just looking at all the wrong examples or something. Below is an example of what I want to do. It is a very dumbed down example just to make my point.
I have a class called "Vehicle". I then have a subclass of that called "Car". Car is then subclasses again as "TwoDoorCar" and "FourDoorCar". These subclasses have no extra properties and are merely for convenience in my code.
I want the "Car" class to be stored in it's own table, inheriting the properties of vehicle when required and I have that done. What I want now is to instantiate the correct TwoDoorCar vs. FourDoorCar objects based on a boolean discriminator when fetching from the DB.
So...in Car.hbm.xml, I have:
Code:
<joined-subclass name="Car" extends="Vehicle" table="CAR">
<key column="CAR_ID" />
<property name="isFourDoor" column="IS_FOUR_DOOR" type="boolean"/>
</joined-subclass>
How do I then map the TwoDoorCar.hbm.xml file (or inline in Car.hbm.xml...I could care less for this simple case)
I can't seem to put a <discriminator column="IS_FOUR_DOOR" type="boolean"/> tag inside a 'joined-subclass' tag, so I'm unsure how to do this. I really want all the Cars to be in 1 table so that when I search for cars, I only look in 1 table, but I also want to be able to have methods that need a 'TwoDoorCar' vs. a 'FourDoorCar' else where in my code.