Container-Managed Relationships

The Container-Managed Relationships dialog box allows you to define the container managed relationships between entity beans in the application. When the dialog is opened existing container managed relationships are represented by lines in the table. A line may be selected for editing or deletion, or a new relationship may be added to the list.

The EJB A column contains the names of EJBs whose relationships are being defined. The EJB B column contains the names of the EJBs being related to the EJB A item. The reference of each to the other (if any) is in the Bean B Ref and Bean A Ref columns. The nature of the relationship, e.g. one to many, is given in the "Multi" column.

Clicking on the Add button opens the Add Relationship dialog for the definition of a new container managed relationship. Clicking the Edit button opens the Edit Relationship dialog for editing an existing container managed relationship. These dialogs are the same except that the Add Relationship dialog opens with no data filled in while the Edit Relationship dialog opens with data from the selected relationship filled in ready for editing.

The EJB name fields are dropdown lists containing known entity EJBs in the JAR. Listed EJBs may be selected for defining or editing relationships. When an EJB has been selected, the bean will be introspected and its container managed reference (CMR) fields will be listed in the Field Referencing Bean X field.

The Multiplicity drop-down box allows the choice of the nature of the relationship from the following:

When Adding the names of the beans and their relationships, references must be filled in.

The boxes for marking what happens to the bean when the other EJB is deleted define the "Cascade Delete" behavior of a bean in the relationship. The box is disabled if the other bean is not a bean in the relationship. When the box is checked the bean is deleted whenever the other bean is deleted.

Clicking OK brings back the Container Managed Relationships dialog with the new relationship showing as a row in the table.

An EJB must have local interfaces defined before it can be referenced by by a CMR field of another bean. On OK an error dialog is presented when a CMR field references an EJB for which local interfaces have not been defined.

To remove a relationship, select a row from the table and click Delete.


Copyright 1999-2001 Sun Microsystems, Inc. All Rights Reserved.