Skip Headers
Oracle® Application Server TopLink Mapping Workbench User's Guide
10g Release 2 (10.1.2)
Part No. B15900-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
 

Implementing a Many-to-Many Mapping

Many-to-many mappings represent relationships between a collection of source objects and a collection of target objects. In the advanced tutorial, the projects attribute uses a many-to-many-mapping (for example, many employees can have many projects).

To map a many-to-many mapping:

  1. Expand the Employee descriptor in the Navigator pane.

  2. Click the projects attribute of the Employee descriptor.

  3. Many to many mapping button.
    Description of the illustration mmmapbtn.gif

    Click the Many-to-many Mapping button on the mapping toolbar.

  4. Use the Reference Descriptor drop-down list to choose the BaseProject descriptor.

  5. Use the Relation Table drop-down list to choose the PROJ_EMP table (the class to map to).

  6. Ensure that the Use Indirection field is selected. See "Implementing Indirection in the Tutorial".

    Figure B-41 Many-to-Many Mapping General Tab

    Description of mmmap.gif follows
    Description of the illustration mmmap.gif

  7. Click the Source Reference tab, and add a new reference by clicking the New button.

    • Create a new reference named PROJ_EMP_EMPLOYEE, with a source table of PROJE_EMP and target table of EMPLOYEE, and click OK.

    • In the Table Reference drop-down list, choose the PROJ_EMP_EMPLOYEE reference.

    • Click the Add button on the Source Reference tab to add a foreign key relationship.

    • Set the Foreign Key field to EMP_ID (from the PROJ_EMP table).

    • Set the Primary Key field to EMP_ID (from the EMPLOYEE table).

  8. Click the Target Reference tab, and add a new reference by clicking the New button.

    • In the Table Reference drop-down list, choose the PROJ_EMP_PROJECT reference.

    • Click the Add button on the Source Reference tab to add a foreign key relationship.

    • Set the Source Field field to PROJ_ID (from the PROJ_EMP table).

    • Set the Target Field field to PROJ_ID (from the PROJECT table).

  9. Save button.
    Description of the illustration savebtn.gif

    Click Save on the toolbar or choose File >  Save Project to save the project.