Configuring CMP Mappings

See Also

If you are deploying to the Sun Java System Application Server, the CMP mappings for your EJB module are stored in the module's src/conf/sun-cmp-mappings.xml file. You may need to change the CMP mappings of your entity beans in the following situations:

When you map the beans in the Sun Configuration editor, you specify the schema and the primary table for each bean. Each bean must be mapped to at least one table within a single database schema. You can also map a bean to a secondary table. All beans related by container-managed relationships must be mapped to tables in the same schema.

To map a CMP entity bean to a database:

  1. If you do not have a database schema, you can capture the schema by selecting Databases > Schema in the New File wizard and saving the schema in the src/conf directory of your project.
  2. In the Projects window, expand the Configuration Files node for your EJB module and double-click sun-cmp-mappings.xml or sun-ejb-jar.xml.
  3. Expand the Sun Configuration node and select the bean you want to map.
  4. In the Cmp Mapping tab of the bean, click Advanced Settings and choose the database schema from the combo box in the dialog box and click OK.
  5. Select the primary table for the bean from the Primary Table drop-down list in the CMP Mapping tab.
  6. You can click Automap All to automatically map the fields according to the schema. You may still need to map some fields manually if any of the fields are not mapped correctly. For example, if the Field name and the Mapped Column name do not match, the IDE may not recognize they should be mapped to each other.
  7. To manually map a bean field, select the appropriate entry in the Mapped Column column. You can choose any of the following:

The IDE saves your changes to the sun-cmp-mappings.xml file when you save your changes.

See Also
About EJB 2.1 CMP Mappings
Generating CMP Entity Beans from a Database
Obtaining a Database Schema
Configuring CMP Mappings
Mapping CMP Fields to Multiple Columns

Legal Notices