Using the Wizard to Create an Entity Bean

The Entity Bean Wizard consists of several pages:

EJB Type Page

Allows you to select the type of persistent storage your Entity EJB will use:

Database Table Page

This page appears when you are creating a CMP EJB and you want the wizard to create the persistent fields for the EJB based on the fields of a table in an existing database. When you select this option, the EJB wizard displays the following page:

Persistent Fields

This page appears when you are creating a CMP EJB and you have EJB persistent fields that map to fields in your database. You can identify multiple fields, but you cannot continue to the next page of the wizard until you designate a primary key field.

If you do not have a primary key defined in your database table, you will need to go back to the database schema and define a primary key so you can use this EJB wizard page.

To add a new field to the list:

  1. Select Add.
  2. In the Add Persistent Field dialog box, enter the name of the field and the data type for the field.
  3. Press Enter or select OK to create the new field.

To edit a field in the list:

  1. Select the field.
  2. Select edit.
  3. In the Edit Persistent Field dialog box, edit the fields as desired.
  4. Press Enter or select OK to save your changes.

To delete a field:

  1. Select the field.
  2. Select the Remove button.

Existing Bean and/or Primary Key Java Class

This appears when you are creating a CMP and you have an existing JavaBean, or primary key class, or both; and you want to use them as the model for the EJB you are creating.

To use an existing bean class:

  1. Select the Select Class... button.
  2. Navigate to the desired bean class.
  3. Optionally, select the Use Existing Bean Class checkbox to use this bean class in the creation of your EJB.

To use an existing primary key class:

  1. Select the Select Class... button.
  2. Navigate to the desired primary key class.
  3. Optionally, select the Use Existing Primary Key Class checkbox to use this primary key class in the creation of your EJB.

You will not be able to proceed to the next page of the wizard if you don't have at least one checkbox selected.

Components Page

This page appears when you are creating a Bean Managed Persistence or you are creating a CMP bean with the No Mapping Information at this time option. You are prompted to identify the following fields:
  • Name Enter a name for the EJB. If you haven't set any of the related objects yet, you will see the default names change to match this one. The default names are based on the recommended default names in the J2EE specification available from the web page at http://java.sun.com/j2ee/.
  • Package Select the Browse button to choose the package that will contain the EJB.
  • Related Objects This section of the dialog box shows the standard components of an entity EJB that are automatically setup for you. If you want to specify any of these components yourself, select the Modify button next to the component. You will be able to enter your changes in the Modify Component dialog box.

    See also
      Creating an EJB
    About Entity Beans


    Legal Notices