-->
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: mapping multiple inhertance table per class + discriminator
PostPosted: Thu Nov 19, 2009 1:24 pm 
Newbie

Joined: Sun Mar 01, 2009 11:44 pm
Posts: 6
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.


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.