Skip Headers
Oracle TopLink Developer's Guide
10g Release 3 (10.1.3)
B13593-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

Step 3: Associating Descriptors to Tables

To associate a descriptor with a database table, use this procedure:

  1. Expand the Employee project icon and the examples.servletjsp.modelpackage in the Navigator.

  2. Select the Address descriptor in the Navigator. Its properties appear in the Editor.

  3. Select the Descriptor Info tab. The Descriptor Info tab appears.

  4. In the Associated Table field, select the ADDRESS table. Notice that TopLink Workbench also correctly identifies the primary key for the table (if supported by your database driver).

    If your database driver does not allow TopLink Workbench to identify the primary key, click Add to add the primary key, as indicated in the tables in "Data Model".

    Figure 17-10 Descriptor Info Tab

    Description of Figure 17-10  follows
    Description of "Figure 17-10 Descriptor Info Tab"

  5. Use the following information to associate the remaining descriptors with database tables:

    Associate This Descriptor... With This Database Table...
    Employee EMPLOYEE
    LargeProject LPROJECT
    PhoneNumber PHONE

    Notice that the PHONE table has a compound primary key: EMP_ID and TYPE.

    Project PROJECT
    SmallProject PROJECT

  6. Save button.
    Click Save to save the project.

Notice that the EmploymentPeriod descriptor is not associated with any database tables. This class will acquire its characteristics through aggregation, later in this tutorial.

Associating With Multiple Tables

In this project, the Employee class is stored in multiple tables; although most information is in the EMPLOYEE table, salary information is stored in the SALARY table.

To spread classes across two or more tables, use this procedure:

  1. Right-click the Employee descriptor in the Navigator and select Select Advanced Properties from the context menu. The Select Advanced Properties dialog box appears.

  2. Select Multitable Info and click OK. TopLink Workbench adds the Multitable Info tab to the Editor.

  3. Click the Multitable Info tab. The Multitable Info tab appears. The Primary Table (EMPLOYEE) has already been selected.

    Figure 17-11 Multitable Info Tab

    Description of Figure 17-11  follows
    Description of "Figure 17-11 Multitable Info Tab"

  4. Click Add to add an additional table. The Select Associated Table dialog box appears.

  5. Select the SALARY table, and click OK.

  6. On the Multitable tab, select the Primary Keys Have the Same Name option.

  7. Save button.
    Click Save to save the project.

Descriptor-Level Sequencing

To specify custom (nonnative) sequencing for the Employee class, use this procedure:

  1. Select the Employee descriptor in the Navigator. Its properties appear in the Editor.

  2. Click the Descriptor Info tab. The Descriptor Info tab appears.

    Figure 17-12 Descriptor Info Tab, Sequencing Options

    Description of Figure 17-12  follows
    Description of "Figure 17-12 Descriptor Info Tab, Sequencing Options"

  3. Use the following information to complete the Sequencing options on the Descriptor Info tab:

    Field Description
    Use Sequencing Specify that the Employee descriptor uses custom sequencing.
        Name Type EMP_SEQ as the name of this sequence.
        Table Select the EMPLOYEE database table.
        Field Select the EMP_ID database field.

  4. Save button.
    Click Save to save the project.

Repeat these steps to use descriptor-level sequencing for the Address descriptor. Use the following information to complete the Sequencing information for the Address descriptor:

Field Description
Use Sequencing Specify that the Address descriptor uses custom sequencing.
    Name Type ADDRESS_SEQ as the name of this sequence.
    Table Select the ADDRESS database table.
    Field Select the ADDRESS_ID database field.