Oracle® Application Server TopLink Mapping Workbench User's Guide
10g Release 2 (10.1.2) Part No. B15900-01 |
|
Previous |
Next |
Some object models require a class to reference another instance of the same class. In the advanced tutorial, a manager can have a collection of managed employees (see Figure B-1).
To map the managedEmployee attribute:
Description of the illustration 1mmapbtn.gif
Select the Employee's managedEmployees
attribute in the Navigator pane, then click the One-to-Many Mapping button on the mapping toolbar.
The Editor pane displays the appropriate information for a one-to-many relationship to be specified.
Use the Reference Descriptor drop-down list to choose Employee
.
Select the Use Indirection option, and choose ValueHolder. See "Implementing Indirection in the Tutorial".
Click the Table Reference tab. Use the Table Reference drop-down list to choose the EMPLOYEE_EMPLOYEE table (previously created in "To map the manager attribute:").
Click the Add button on the Table Reference tab to add a foreign key relationship.
Set the Source Field (foreign key) to MANAGER_ID
.
Set the Target Field (primary key) to EMP_ID
.
Description of the illustration savebtn.gif
Click Save on the toolbar or choose File > Save Project to save the project.
The Advanced tutorial also includes a one-to-many mapping for the phoneNumbers
attribute in the Employee
descriptor. Create this mapping as shown in "Creating One-to-Many Mappings". Refer to Table B–14 for the correct relationship.
Enable indirection for this mapping, as indicated in "Implementing Indirection in the Tutorial".