-->
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.  [ 2 posts ] 
Author Message
 Post subject: Inheritance- combining tbl per hierarchy & tbl per subcl
PostPosted: Thu Sep 20, 2007 10:06 am 
Regular
Regular

Joined: Thu Nov 30, 2006 10:48 am
Posts: 59
(although we're using nHibernate, this should apply to Hibernate overall) -- I created an ADO version of our O/R layer for the first phase of our project (this means we already have the database tables). I'm now in the process of providing an nHibernate version.

Note: The question is: How can I get an inheritance implementation that uses both tbl per hierarchy and tbl per subclass to work? Given that hibernate says that subclass and joined-subclass can't be combined, does that mean I have to create a table for each subclass?

Details:

We have a Device class hierarchy where there's an abstract Device class w/ common attributes for all devices. Each device (Router, Workstation, Switch, Hub, etc.) has its own concrete class that derives from the Device class. Most of these concrete classes add nothing of their own, inheriting behavior and properties from the Device class.

The database implements the inheritance with a combined approach where there's a Device table (tblDevice) that has the attributes common to all devices (with a discriminator field) and other tables are created only for devices (such as Router and Switch) that have additional attributes (and these tables have a foreign key to the Device table). A further complication is that the discriminator is not directly in the Device table; instead we have a DeviceType table and the Device table has a foreign key to DeviceType's primary key field.

    tblDevice: primary key = Identity (int) field
    tblDeviceType: primary key = Identity (int) field; other columns: dtype (varchar)
    tblRouter: primary key = Identity (int) field; has a foreign key to tblDevice for inheritance

Thanks,
Bill

_________________
metazone


Last edited by metazone on Thu Sep 20, 2007 11:36 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 20, 2007 11:34 am 
Regular
Regular

Joined: Thu Nov 30, 2006 10:48 am
Posts: 59
Note: The question is: how can I get this to work? Given that hibernate says that subclass and joined-subclass can't be combined, does that mean I have to create a table for each subclass?

_________________
metazone


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