Skip Headers

Map Inheritance Relationships

Previous
Previous
 
Next
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.

Show me...

  1. Right-click the Project descriptor in the Structure window and select Advanced Properties > Inheritance. The Project properties page appears in the Editor.

  2. Select the Inheritance tab.

  3. Select the Is Root Descriptor option to indicate that the Project class is the root (that is, the "parent") of this inheritance relationship.

  4. 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.

  5. 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.

  6. 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.

Inheritance Tab

Inheritance tab

 

Adding Children to the Inheritance Relationship

We have already configured the Project class as the parent – now we must configure the children classes: LargeProject and SmallProject.

  1. Right-click the LargeProject descriptor in the Structure window and select Advanced Properties > Inheritance. The Project properties page appears in the Editor.

  2. Select the Inheritance tab.

  3. Unselect the Is Root Descriptor option.

  4. In the Parent Descriptor field, select the Project descriptor.

Repeat this procedure to add the SmallProject to the inheritance mapping as a child.

 

Creating the Class Indicator Dictionary

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.

  1. Select the Project descriptor in the Navigator. The Project properties page appears in the Editor

  2. Click the Inheritance tab. TopLink has already added the LargeProject and SmallProject classes to the Indicator Dictionary area.

  3. Select to Include both the LargeProject and SmallProject classes.

  4. Select the Indicator Value field for the LargeProject and click Edit. The Enter an Indicator Value dialog appears.

  5. In the Indicator Value field, type L and click OK.

  6. Repeat steps 45 for the SmallProject, using S as the indicator value.

Class Indicator DIctionary

Class Indicator fields