Creating Many-to-Many Mappings
Use this procedure to create a many-to-many mapping.
To create a many-to-many mapping:
- In the Application Navigator, select the attribute to be mapped.
- Click the Many-to-Many Mapping button
on the mapping toolbar.
- Use the Reference Descriptor drop-down list to choose the reference descriptor for this mapping.
- Use the Relation Table drop-down list to choose the relation table.
- Use the Maintain Bidirectional Relationship option to select a Relationship Partner for this mapping. See "Maintaining Bidirectional Relationships" for more information.
- Modify any other properties, as needed. See "Working with Common Mapping Properties" for more information.
- Click the Collection Options tab to specify how the source descriptor relates to the relation table. See "Specifying Collection Properties" for more information.
- Click the Source Reference tab to specify how the source descriptor relates to the relation table.
- Use the Table Reference drop-down list to choose a reference whose foreign key is in the relation table and that points to a table associated to the source descriptor.
- Click the Target Reference tab to specify how the reference descriptor relates to the relation table.
- Choose a reference whose foreign key is in the relation table and that points to a table associated to the reference descriptor.
Specifying Advanced Features by Amending the Descriptor
TopLink can populate a collection in ascending or descending order, upon your specification. To do this, specify and write an amendment method, sending the addAscendingOrdering() or addDescendingOrdering() to the many-to-many mapping. Both messages expect a string as a parameter, which indicates what attribute from the target object is used for the ordering. This string can be an attribute name or query key from the target's descriptor. Query keys are automatically created for and with the same name as all attributes mapped as direct-to-field, type conversion, object type, and serialized object mappings.
Copyright © 1997, 2004, Oracle.
All rights reserved.