Map Inheritance Relationships |
![]() Previous |
![]() Next |
Inheritance describes how a child class inherits the characteristics of its parent class.
In this step, we will map the inheritance relationship for the Project, SmallProject and LargeProject classes, as shown in Example: Object Model.
For more information, see "Understanding Descriptors and Inheritance" in Oracle Toplink Developer's Guide.
Right-click the Project descriptor in the Structure window and select Select Advanced Properties. The Select Advanced Properties dialog appears.
Select the Inheritance option and click OK. The Inheritance Info tab appears in the Editor.
Select the Inheritance tab.
Select the Is Root Descriptor option to indicate that the Project class is the root (that is, the "parent") of this inheritance relationship.
Select the Use Class Indicator Field option and select PROJ_TYPE as the field.
The class indicator is used to specify the class stored in a particular row. We will use the PROJ_TYPE field to determine if the projects in this inheritance relationship are "large" projects or "small" projects.
Select the Use Class Indicator Dictionary option. Leave the Indicator Type as String.
A class indicator dictionary is a collection of key-values that associates a simple key, stored in the row, with a class. After adding the other classes to this inheritance relationship, we will add indicator types for each class.
Select the Read Subclasses on Query option.
By selecting this option, any queries for Projects will also return items from its subclasses that match the query.
We have already configured the Project class as the parent – now we must configure the children classes: LargeProject and SmallProject.
Right-click the LargeProject descriptor in the Structure window and select Select Advanced Properties. The Select Advanced Properties dialog appears.
Select the Inheritance option and click OK. The Inheritance Info tab appears in the Editor.
Select the Inheritance tab.
Select the Is Child Descriptor option.
In the Parent Descriptor field, select the Project descriptor.
Repeat this procedure to add the SmallProject to the inheritance mapping as a child.
When configuring the Project descriptor as the parent, we specified to use a class indicator dictionary. In this step we will configure the add keys for each child class in the inheritance.
Select the Project descriptor in the Navigator. The Project properties page appears in the Editor
Click the Inheritance tab. TopLink has already added the LargeProject and SmallProject classes to the Indicator Dictionary area.
Select to Include both the LargeProject and SmallProject classes.
Select the Indicator Value field for the LargeProject and click Edit. The Enter an Indicator Value dialog appears.
In the Indicator Value field, type L and click OK.
Repeat steps 4 – 5 for the SmallProject, using S as the indicator value.