Download PDF Home History |  | API Search Feedback FAQ

> ## 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.

> 1. 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.
> 2. Enter values in the Primary Key Class and Primary Key Field Name fields. The primary key uniquely identifies the entity bean.
> 3. 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.

> 1. To open the Finder/Select Methods dialog box, go to the Entity tab and click Finder/Select Methods.
> 2. To display a set of finder or select methods, click one of the radio buttons under the Show label.
> 3. 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.

> 1. Before you create a relationship between two entity beans, you must first create both beans using the New Enterprise Bean wizard.
> 2. To display the Relationships tab, select the EJB JAR in the tree view and then select the Relationships tab.
> 3. To add or edit a relationship, go to the Relationships tab and click the appropriate button.
> 4. 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 in `deploytool`.

> 1. Select `TeamJAR` in the tree in `deploytool`.
> 2. Select the Relationships tabbed pane.
> 3. Click Sun-specific Settings.
> 4. Click Create Database Mappings.
> 5. Select Automatically Generate Necessary Tables.
> 6. Click OK.

> When you deploy `RosterApp`, the tables will be created and named according to the values in the Persistent Field Mappings table.

Download PDF Home History |  | API Search Feedback FAQ

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.