CMP relationships are managed by the container based on how the relationships are described
in the ejb-jar.xml general deployment descriptor.
To modify CMP relationships in ejb-jar.xml:
In the Projects window, expand the Configuration Files node for the EJB
module project and double-click ejb-jar.xml.
In the top of the graphical editor, click CMP Relationships.
The visual editor displays a table of the existing container-managed relationships for the EJB module.
Double-click the name of the relationship in the table to open the Edit CMP Relationship dialog box.
Edit the relationship description properties in the dialog box.
Click OK.
When you edit the relationship in ejb-jar.xml, you may also need
to make corresponding changes in your source code.
To remove a CMP relationship in ejb-jar.xml:
In the Projects window, expand the Configuration Files node for the EJB
module project and double-click ejb-jar.xml.
In the top of the graphical editor, click CMP Relationships.
The visual editor displays a table of the existing container-managed relationships for the EJB module.
Select the name of the relationship in the table and click Remove
Creating a CMP Relationship
If you are you are generating CMP entity beans from scratch and need to specify the CMP relationships for
your application, you need to edit the deployment descriptor file in the XML editor.
You also need to make the corresponding changes in your source code.
When working with CMP entity beans, the IDE does not update your source code based on changes you make in ejb-jar.xml.
To create new CMP relationships in ejb-jar.xml:
In the Projects window, expand the Configuration Files node for the EJB
module project and double-click ejb-jar.xml.
Click the XML tab and edit the deployment descriptor file in the XML editor.
Each CMP relationship requires the following.
A relationship name.
Each end of the relationships requires that the following is defined.
A distinct name for the relationship role and the entity bean in which
the relationship begins or ends.
The multiplicity of the relationship.
Whether cascade delete is enabled for the either side of the relationship.
When you enable cascade delete for a bean in a relationship, deleting
the bean also deletes the bean it is related to.
Whether to create a Container-Managed Relationship (CMR) field for the
bean. If you create a CMR field, the application server can search for
and return instances of the bean field references. The name of the
class must begin with a lower-case letter.
The return type of the CMR field. If the multiplicity of the bean it
is returning is one, you do not have to specify a return type. The application
server automatically returns the enterprise bean's interface.
If the multiplicity is set to many, you can choose whether to return
java.util.Set or java.util.Collection. Choose java.util.Set
if the returned beans cannot be duplicates. Choose java.util.Collection
if the returned beans can include duplicates.
Notes:
When you generate CMP entity beans from a database, the IDE automatically
registers all of the container-managed relationships based on the relationships
in the database.
Changes in the ejb-jar.xml deployment descriptor can result in
automatic or necessary changes in the corresponding application server-specific
deployment descriptors. For example, when you add a relationship in ejb-jar.xml,
you have to map it to a real database in the server-specific deployment descriptor.
You should exercise caution when editing deployment descriptors in XML and always validate your XML file to avoid errors.
For a complete list of configurable properties for
all J2EE module types, see "Appendix A
Deployment Descriptor Files" in
the Sun Java System Application Server Developer's
Guide.
For a detailed description of CMP entity bean specifications, see the Enterprise JavaBeans Specification, v2.1.