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:
- The generated defaults are not adequate
- You have modified your bean
- You have modified your schema
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:
- 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.
- 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.
- If either sun-cmp-mappings or sun-ejb-jar.xml are
open in the text mode, you cannot open the visual editor. You first have
to close the text mode tabs in the Source Editor.
- Expand the Sun Configuration node and select the bean you want to map.
- 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.
- Select the primary table for the bean from the Primary Table drop-down list
in the CMP Mapping tab.
- 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.
- To manually map a bean field, select the appropriate entry in the Mapped
Column column. You can choose any of the following:
- A single column name. Maps the field to a single column in the
primary table.
- <map multiple columns>.
Maps the field to multiple columns in the primary and secondary tables.
- <mapped relationship>.
Configures a container-managed relationship between two tables.
The IDE saves your changes to the sun-cmp-mappings.xml file when you
save your changes.
- If you are using a mapping file (sun-cmp-mappings.xml) without
capturing the database meta data (a schema file), your mapping is not shown
in the Field Mappings table. However, this mapping file is still valid and
deployable. You can continue to use this mapping file.
- 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