Given an object hierarchy where ThirdObject extends SecondObject which extends FirstObject, is the following schema for a table-per-subclass hierarchy ok?
Table 1
Code:
FirstObjects
------------
firstObjectId (PK, IDENTITY)
propertyOfFirstObject
Table 2Code:
SecondObjects
-------------
secondObjectId (PK, IDENTITY)
firstObjectId (FK)
propertyOfSecondObject
Table 3Code:
ThirdObjects
------------
thirdObjectId (PK, IDENTITY)
secondObjectId (FK)
propertyOfThirdObject
The table for each subclass has its own primary key which is an MS SQL Server IDENTITY column. Further, each subclass's table has a FK column which relates to the PK column of the parent class's table (FK secondObjectId in table ThirdObjects relates to PK secondObjectId in table SecondObjects, and so on). So again, is this schema correct for table-per-subclass hierarchy?
Second question, with regards to the PK columns in each subclass table, should they be included in the mapping for each subclass or not? Is the following mapping correct?
Code:
<class name="FirstObject" table="FirstObjects">
<id name="firstObjectId" type="long">
<generator class="native"/>
</id>
<property name="propertyOfFirstObject"/>
<joined-subclass name="SecondObject" table="SecondObjects">
<key column="firstObjectId"/>
<property name="propertyOfSecondObject"/>
<joined-subclass name="ThirdObject" table="ThirdObjects">
<key column="secondObjectId"/>
<property name="propertyOfThirdObject"/>
</joined-subclass>
</joined-subclass>
</class>
Is it correct that the PK columns for the subclasses are omitted from the mapping document entirely? Should they be in there with insert="false" and update="false"? Should they be in there as ids as with the parent class?
Hope the above was clear. Thanks, greatly, in advance, and kudos on a phenomenal tool!
Brian St.Clair