Download
FAQ History |
API
Search Feedback |
deploytool Tips for Entity Beans with Container-Managed Persistence
Chapter 24 covers the basic steps for building and packaging enterprise beans. This section highlights the tasks in
deploytool
that are needed for entity beans with container-managed persistence. The examples referenced in this section are from A Guided Tour of the RosterApp Settings.Selecting the Persistent Fields and Abstract Schema Name
In the Entity tab of the enterprise bean, enter the field information and the abstract schema name.
- In the Fields To Be Persisted list, select the fields that will be saved in the database. The names of the persistent fields are determined by the access methods defined in the entity bean code. Be sure not to select container-managed relationship fields.
- Enter values in the Primary Key Class and Primary Key Field Name fields. The primary key uniquely identifies the entity bean.
- In the Abstract Schema Name field, enter a name that represents the entity bean. This name will be referenced in the EJB QL queries.
An example is shown in the section Entity Tab (PlayerBean).
Defining EJB QL Queries for Finder and Select Methods
You specify these settings in the Finder/Select Methods dialog box.
- To open the Finder/Select Methods dialog box, go to the Entity tab and click Finder/Select Methods.
- To display a set of finder or select methods, click one of the radio buttons under the Show label.
- To specify an EJB QL query, choose the name of the finder or select method from the Method list, and then enter the query in the field labeled EJB QL Query.
An example is shown in the section Finder/Select Methods Dialog Box (PlayerBean).
Defining Relationships
The Relationships tab enables you to define relationships between entity beans that reside in the same EJB JAR file.
- Before you create a relationship between two entity beans, you must first create both beans using the New Enterprise Bean wizard.
- To display the Relationships tab, select the EJB JAR in the tree view and then select the Relationships tab.
- To add or edit a relationship, go to the Relationships tab and click the appropriate button.
- The Add (or Edit) Relationship dialog box appears. (The Add Relationship and Edit Relationship dialog boxes are identical.)
An example is shown in the section Edit Relationship Dialog Box (TeamJAR).
Creating the Database Tables at Deploy Time in deploytool
The
RosterApp
example uses a database schema file to map database tables to enterprise bean fields. Alternatively, you can have the container create the database tables at deploy time by setting some options indeploytool
.When you deploy
RosterApp
, the tables will be created and named according to the values in the Persistent Field Mappings table.
Download
FAQ History |
API
Search Feedback |
All of the material in The J2EE(TM) 1.4 Tutorial is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.