Right-click the filesystem you have created for the EJB files and choose New -> Java Package. Name the new package and click Finish.
The IDE displays the new package in the filesystem.
The Related CMP Entity Beans wizard opens.
JAR
in the EJB Module Name field.The Select Database Schema Object pane is displayed.
The four tables that you selected previously are listed in the Available Tables list.
The four tables are moved to the Selected Tables list.
The Edit CMP Entity EJB Data pane is displayed.
If all the beans you are using are accessed only from the session bean, make sure that Local Interfaces Only is selected in the Component Interfaces radio button box.
id (PK)
) and make any desired changes to the CMP Field Name field.For strings, select java.lang.String
, for doubles double
, etc.
(CMR to
name)
, and make any necessary changes to the EJB Relation Name, Role Name, CMR Field Name, and CMR Type fields.The entry in the EJB Relation Name should have the form bean1 nameEJB-
bean 2 nameEJB
.
The Role Name can match the name of the table listing. The CMR field name refers to the related bean. The Multiplicity field shows the nature of the relationhip, either One
or Many
. The CMR Type is the variable type.
For example, in the sample Roster application that ships with Sun ONE Application Server, one EJB relationship is between the TeamEJB
and LeagueEJB
. For this relationship:
TeamEJB-LeagueEJB
.Team
, the CMR Field Name is league
, and the
Multiplicity is Many
, i.e., many teams in a league.League
, the CMR Field Name is teams
, and the
Multiplicity is One
, i.e., a team can only be part of one league.java.util.Collection
.The infrastructure of your set of related CMP entity beans (the bean classes, their local interfaces and local home interfaces, and the interbean relationships) is generated automatically by the EJB Builder.
After creating related CMP enterprise beans, you can examine their relationships from the IDE Explorer.
The Edit EJB Relation editor opens.
The EJB Builder assigns the correct mappings for the fields in the CMP enterprise beans you create. You can examine the results.
To view mappings for the CMP entity bean fields:
The EJB fields are already mapped. CMP fields of the bean are mapped to corresponding columns in the corresponding database table, where thier values will be stored. CMR fields of the bean are mapped to the corresponding relationship.
The Relationship Mapping editor appears displaying the Initial Setup pane.
The field's database table linking is shown.
The Map to Key pane is displayed. The columns used in the linking are shown.