Mapping Relationships to Existing Tables
If you engineer entity beans from database tables, foreign keys are
interpreted as EJB relationships. However, if you have existing entity
beans and existing database tables, you will need to map the
relationships accordingly.
To map entity beans relationships, you use the Relationship Mappings
editor.
To map entity beans to tables:
-
If you have not already done so, establish a connection to the
database schema(s) you want to use.
-
In the Navigator, right-click on an entity bean and choose
Edit CMP Mappings.
The CMP Field Mappings editor opens.
-
Click on the Relationship Mappings tab.
-
Use the CMP Relationship Mappings editor to map relationships.
Note
that the Association Table checkbox may become selected by default
under some circumstances (changing a table name, for example). This
happens because the mapping tool tests for whether an association
table is being used by comparing the table specified in the
collection-mapping (1 end of a 1:* relationship) with the table used
by the * end of the CMP field mapping. If they are different, the
mapping tool indicates an intersection table is being used, though it
may be detecting pre-existing field mappings.
For additional help
in the editor, click Help in the dialog or
press F1.
Note that a single column can map to both a CMP field and a CMR field,
but a field is either
CMP or CMR but not both. For compound primary
keys, one field may be mapped to a CMP field and the other to a CMR
field.
-
If you need to define additional relationships, double-click any EJB
in the Navigator to open the EJB Module Editor. For additional help in
the editor, click Help in the dialog or
press F1.
Related topics
Creating a Diagram of
Enterprise JavaBeans
Developing Enterprise JavaBeans
What are Enterprise JavaBeans?
Copyright © 1997, 2004, Oracle. All rights reserved.