Defining CMP2.0 relationships
Use the Define CMP2.0 Relationships wizard to define the relationships of a container-managed persistence Entity Bean having EJB2.1 specifications. Use this wizard to set the relationships of an Entity Bean with other Entity Beans. Therefore, an EJB2.1 Container-managed persistence Entity Bean used for definitions of the relationships under the same project must be created before Define CMP2.0 Relationships wizard can be used.
From [New] wizard, select [EJB] > [J2EE] > [CMP2.0 Relationship] to select the Define CMP2.0 Relationships wizard. Check and enter the settings shown below.
Specifying the Deployment Descriptor
Specify the deployment descriptor file of Entity Beans to define their relationships.
Option | Description |
---|---|
ejb-jar.xml file | Specify the path of ejb-jar.xml. |
Specifying CMP2.0 Relationship Information
Specify the relationships between Entity Beans.
Option | Description |
---|---|
Add | Add new relation. |
Delete | Delete the relation selected on the list. |
Edit | Edit the relation selected on the list. |
Reflect relation information in a Home/Component interface | When this option is checked, the CMR field access information is reflected in the Local/Component interface. |
Adding or Editing a CMP Relationship
Specify the relation between Entity Beans.
For ease of use, the two Enterprise Beans whose relationship is defined are assumed to be Enterprise Bean A and Enterprise Bean B.
Option | Description |
---|---|
EJB relation name | Specify a name for the relation between Entity Beans. The EJB relation name can be omitted. |
Multiplicity | Specify the multiplicity of relation of Entity Beans. Multiplicity of relation indicates the correspondence relation between Enterprise Beans making up the relationship. The multiplicity of relation is a one-to-one, one-to-many, or many-to-many relation. |
EJB relationship role name | Specify a relationship role name for each Entity Bean making up the relation. The EJB relationship role name can be omitted. |
Enterprise Bean name | Specify an Enterprise Bean name for each Entity Bean making up the relationship. |
CMR field for accessing Bean A/B | Specify a CMR field name used for accessing the other Enterprise Bean. Either A or B must be specified. |
CMR field type | Specify the type of CMR field for accessing the other Enterprise Bean in the relation. If the multiplicity of relation is One:Many, Many:One, or Many:Many and the other Enterprise Bean is Many, java.util.Collection or java.util.Set can be specified. |
Delete when Bean A/B is deleted | Specify whether an Enterprise Bean is deleted if the other Enterprise Bean making up the relation is deleted. |
Description | Provide a description explaining this relation definition. The description can be omitted. |
Mapping A tab | Specify the database information for an Enterprise Bean specified to be associated with Enterprise Bean A. If the multiplicity of relation is One:One, be sure to specify the column of the database used to access the primary key of the other Enterprise Bean. |
Mapping B tab | Specify the database information for an Enterprise Bean specified to be associated with Enterprise Bean B. If the multiplicity of relation is One:One, be sure to specify the column of the database used to access the primary key of the other Enterprise Bean. |
Join Table tab | Specify the information in the join table required when the multiplicity of relation is One:Many, Many:One, or Many:Many. |
Specifying Mapping A and Mapping B
Specify the information used for mapping a database table or database columns to the Enterprise Bean fields.
The information specified on this screen is saved in the CMP extension information file.
Option | Description |
---|---|
Data source name | Specify a data source name for the database used to make the associated Enterprise Bean fields persistent. |
Schema name | Specify a schema name for the database used to make the associated Enterprise Bean fields persistent. |
Table name | Specify a table name for the database used to make the associated Enterprise Bean fields persistent. |
PK | Select this item for the Primary key. |
DB Column Name | Specify a column name for the database to be associated with the persistence field |
Related Enterprise Bean Name, Related Field Name | Specify an Enterprise Bean name and field name of the persistence field to be associated with the DB column name. If the multiplicity of relation is One:One, be sure to specify the DB column to be associated with the persistence field of the primary key for the destination Enterprise Bean. |
Add | Add a new line. |
Delete | Delete the line selected on the list. |
Browse DB | Add a line by referring to a database table or column. Clicking the [Browse DB] button displays the login screen. |
Specifying the Join Table
Specify information for the join table created for the multiplicity of relation of One:Many, Many:One, or Many:Many.
The information specified on this screen is saved in the CMP extension information file of Enterprise Bean.
Option | Description |
---|---|
Schema name | Specify a schema name for the Join table used to associate tables with one another. |
Join table name | Specify a name for the Join table used to associate tables with one another. |
PK | Select the primary key item of the join table. The primary key item of the Enterprise Bean on the many side of multiplicity of relation is also used for the join table. Therefore, if the multiplicity of relation is Many:Many, all items become primary keys. |
DB Column Name | Specify a name for a column in the database. |
Related Enterprise Bean Name, Related Field Name | Specify an Enterprise Bean name and field name of the persistence field to be associated with a DB column name. The DB column is required for an association using the primary key items of two Enterprise Beans whose relationship is defined. |
Add | Add a new line. |
Delete | Delete the line selected on the list. |
Browse DB | Add a line by referring to a database table or column. Clicking the [Browse DB] button displays the login screen. |
Refer to the "Interstage Application Server J2EE User's Guide" for relationship definition details.
Editing Deployment Descriptors (ejb-jar.xml)
To edit the deployment descriptor(ejb-jar.xml), use an XML editor. For details, refer to "Editing XML Files".
Creating a CMP extension information file
When the source of an Enterprise Bean class is created separately and if the CMP extension information corresponding to the Enterprise Bean does not exist because of certain reason, then the required CMP extension information file can be generated.
From [New] wizard, select [EJB] > [J2EE] > [CMP Extension Information], and use the wizard to create a CMP extension information file. See below for the wizard settings.
Option | Description |
---|---|
Ejb-jar.xml file | Specify the path of ejb-jar.xml. |
Enterprise Bean name | If the path of ejb-jar.xml is specified, since the list of Container-managed persistence Entity Bean defined will be displayed. Select a CMP extension information file of Enterprise Bean to be generated. |
Note
The CMP Extension Information wizard does not operate with applications for Java EE containers.
Point
CMP extension information file is generated in the root of source folder where the specified ejb-jar.xml exists.
Editing CMP Extension Information Files
To edit CMP extension information files, use the CMP Extension Information File Editor. It is used to edit the mapping between CMF(Container-managed Fields) and databases, and to edit finder method search criteria.
To edit a CMP extension information file, select FJCMP_(Enterprise Bean class name).xml from the [Project Explorer] or similar view, and then select [Open With] > [CMP Extension Information File Editor] from the context menu. Because an editor is associated once you edit a file, you can also start the CMP extension information editor by double-clicking the file or selecting [Open] from the popup menu.
Point
The CMP Extension Information File Editor does not provide a function to display XML as is. To edit XML source directly, use an XML editor.