About EJB 2.1 CMP Mappings

See Also

The term container-managed persistence (CMP) means that the EJB container handles all database access required by the entity bean. When coding to the J2EE 1.4 specification, you create CMP entity beans that are mapped to tables in your sun-cmp-mapping.xml files. The bean's code contains no database access (SQL) calls. As a result, the bean's code is not tied to a specific persistent storage mechanism (database). Because of this flexibility, even if you redeploy the same entity bean to different J2EE servers that use different databases, you do not need to modify or recompile the bean's code. In short, your entity beans are more portable.

In order to generate the data access calls, you have to provide a schema that defines the bean's persistent fields and relationships. Your CMP entity beans mirror the structure of your database. The beans' CMP fields correspond to the columns in the database tables and the relationship fields correspond to foreign keys in the database.

Configuring CMP Mappings in the IDE

If you are deploying to the Sun Java System Application Server, the IDE can assist you in generating and configuring CMP mappings. If you are deploying to a different application server, you have to configure CMP mappings yourself by editing the server-specific deployment descriptors.

There are three strategies for working with CMP mappings in the IDE:

See Also
Defining a CMP Field
Generating CMP Entity Beans from a Database
Obtaining a Database Schema
Configuring CMP Mappings
Mapping CMP Fields to Multiple Columns
Specifying Primary and Secondary Tables
Mapping Relationship Fields
Generating Database Tables at Deployment

Legal Notices