(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