If you are deploying to the GlassFish Server, the CMP mappings for your EJB module are specified in the sun-cmp-mappings.xml descriptor file in the module's src/conf directory. You use the XML editor to configure CMP mappings in sun-cmp-mappings.xml.
You may need to change the CMP mappings of your entity beans in the following situations:
To edit CMP mappings in sun-cmp-mappings.xml:
When you map the beans in sun-cmp-mappings.xml, 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.
A secondary table must be related to the primary table by one or more columns whose associated rows have the same values in both tables. This link is called a reference key. Normally, this key is a foreign key in the primary table.
For more about CMP relationships, see the following topics:
When you map CMP beans to a database, the CMP fields in each entity bean map to columns in either the primary or a secondary table. CMP fields can also be mapped to multiple database columns.
If you map a field to more than one column, all columns will be updated with the value of the first column listed. Therefore, if the value of one of the columns is changed outside of an EJB application, the value will only be read if the change was made to that first column. Writing a value to the database overwrites any conflicting changes made to any other columns.
When you have foreign-key relationships between database tables, you usually want to preserve those relationships in the CMP beans mapped to those tables. Container-managed relationships (CMR) determine how relationships between mapped CMP beans are stored in the database. CMRs enable navigation from one bean to another, in the same way that a foreign key enables navigation from one table to another.