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.
When mapping relationship fields, you typically use a foreign key to connect your tables. If there is no foreign key, then you must create key column pairs to act as the key between tables. The columns in each pair are expected to have the same value.
If you generate CMP entity beans from a database schema, the IDE generates the necessary relationships in the deployment descriptor for you based on the database schema. If you are you are generating CMP entity beans from scratch and need to configure CMRs for your application, you need to edit the deployment descriptor file in the XML editor.
If you are deploying to the GlassFish Server, you configure CMR fields in the sun-cmp-mappings.xml. If you are deploying to a different application server, you have to configure CMR fields yourself in the server-specific deployment descriptors.
To edit CMR field mappings: