-->
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.  [ 5 posts ] 
Author Message
 Post subject: Inheritance Mapping
PostPosted: Fri Aug 20, 2004 9:33 am 
Newbie

Joined: Fri Aug 20, 2004 9:25 am
Posts: 9
Hibernate version:2.14

Name and version of the database you are using:MySQL

Is there any way to achieve the following in Hibernate 2.14.
I have two tables in a database, Asset and PhysicalAsset. PhysicalAsset is a sub-class of Asset and I can map this using joined-subclass. However I which to add additional subclasses of PhysicalAsset which are not tables in the database. e.g. Parcel and Package. There is a further complication in that the discriminator for deciding these classes is held in the Asset table.

This is the simplified database table view:
Asset
id - Unique Id
type - Parcel, Package etc.

PhysicalAsset
id - Unique Id
name - UniqueName
owner - Owner

Is this possible or are there any other approaches I could adopt?

Thanks,

John.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 20, 2004 10:54 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Not in Hibernate 2.1.

HIbernate3 adds support for this kind of thing.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 20, 2004 12:46 pm 
Newbie

Joined: Fri Aug 20, 2004 9:25 am
Posts: 9
Thanks for the quick response. I did think that might be the case, but I was hoping I had missed something. Oh well back to the drawing board.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 29, 2004 12:22 pm 
Newbie

Joined: Fri Aug 20, 2004 9:25 am
Posts: 9
I've download Hibernate3 alpha, but I'm still not sure how I can achieve the mapping. My initial thoughts had been to use a joined-subclass to create the PhyisicalAsset class and then use subclass to create the Package and Parcel classes. This still does not seem possible as I cannot declare a subclass within a joined-subclass.

The following is what I want to get to:

class Asset // Asset is a database table

class PhysicalAsset extends Asset // PhysicalAsset is a database table

class Package extends PhysicalAsset // Package is not a database table

class Parcel extends PhysicalAsset // Parcel is not a database table

Is this mapping possible?

Thanks,

John.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 29, 2004 7:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You would use ordinary <subclass> mapping, together with <join> and perhaps formula-based discriminators.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.