Oracle TopLink Developer's Guide
10g Release 3 (10.1.3) B13593-01 |
|
![]() Previous |
![]() Next |
In variable one-to-one mappings, you can use an indicator column in the source table to specify the correct target table, as illustrated in Figure 41-1. This section includes information on implementing class indicators.
A source table has an indicator column that specifies the target table through the class indicator field.
Figure 41-1 illustrates the EMPLOYEE table that has a TYPE column that indicates the target for the row (either PHONE or EMAIL).
Figure 41-1 Variable One-to-One Mapping using Class indicator Field
The principles of defining such a variable class relationship are similar to defining a normal one-to-one relationship, except:
The reference class is a Java interface, not a Java class. However, the method to set the interface is identical.
You must specify a type indicator field.
You specify the class indicator values on the mapping so that mapping can determine the class of object to create.
You must specify the foreign key names and the respective abstract query keys from the target interface descriptor.
Alternatively, you can use unique primary keys to specify the correct target. See "Configuring Unique Primary Key" for more information.
To specify the class indicators for a variable one-to-one mapping, use this procedure:
Select the variable one-to-one mapping in the Navigator. Its attributes appear in the Editor.
Click the Class Indicator Info tab. The Class Indicator Info tab appears.
Use the Class Indicator Field to select the field on the database table (associated with the mapping's descriptor) to use as the indicator for the variable mapping.
Use the Indicator Type to specify the data type of the class indicator field by selecting the data type from the list.
To specify the specific class indicator field values for each (nonabstract) child class, click Edit and enter the appropriate value for each child class.