The J2EETM Tutorial
Home
TOC
Index
PREV TOP NEXT Search
Feedback

deploytool Tips for Entity Beans With Container-Managed Persistence

Chapter 2 covered 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.

Specifying the Bean's Type

In the New Enterprise Bean wizard, specify the bean's type and persistent management.

  1. In the Edit Contents dialog box, add all of the classes required by the entity bean and by its related beans.
  2. In the General dialog box, select the Entity radio button.
  3. In the General dialog box, specify the local interfaces of the entity bean. (If the bean also has remote interfaces, specify them as well.)
  4. In the Entity Settings dialog box, select the radio button for Container-Managed Persistence (2.0). You may skip the other settings in this dialog box and enter them later in the Entity tab.

Selecting the Persistent Fields and Abstract Schema Name

In the Entity tab, 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.
  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 (PlayerEJB).

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 (PlayerEJB).

Generating SQL and Specifying Table Creation

In deploytool, the various Deployment Settings dialog boxes enable you to enter information needed by the server at runtime. These settings are specific to the J2EE SDK implementation.

  1. To open the Deployment Settings dialog box, go to the Entity tab and click Deployment Settings.
  2. With container-managed persistence, the container can automatically create or delete the database table used by the entity bean. If you've loaded test data into the table, you may want to deselect the checkboxes in the Database Table box.
  3. To translate the EJB QL queries into SQL SELECT statements, click Generate Default SQL. If this button is disabled, you must first specify the database settings.

An example is shown in the section Entity Deployment Settings Dialog Box (PlayerEJB).

Specifying the Database JNDI Name, User Name, and Password

You specify these settings in the Database Settings dialog box.

  1. To open the Database Settings dialog box, go to the Entity tab and click Deployment Settings. In the Deployment Settings dialog box, click Database Settings.
  2. Enter a value in the Database JNDI Name field. The examples in this book use the jdbc/Cloudscape JNDI name.
  3. The Cloudscape database shipped with the J2EE SDK does not require a user name or password. So, if your bean connects to the Cloudscape database, you may leave the User Name and Password fields blank. To connect to other types of databases, you may need to enter values into these fields.

An example is shown in the section Database Deployment Settings Dialog Box (PlayerEJB).

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 with 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 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).

Home
TOC
Index
PREV TOP NEXT Search
Feedback