Defining a CMP Field

See Also

An EJB 2.1 entity bean is the tool that a J2EE 1.4 enterprise application uses to represent data in a database. If it uses container-managed persistence (CMP), the bean must have a set of CMP fields that the container uses to map to fields in the database.

To define a CMP field for an existing entity bean:

  1. Open the bean class in the Source Editor.
  2. Right-click anywhere inside the body of the class and choose EJB Methods > Add CMP Field. This command is only enabled when you click within the body of the class (after the class declaration).
  3. You can also right-click enterprise bean's node in the Projects window and choose Add > Add CMP Field.

  4. Enter the name and type of the CMP field and click OK.

When you add a new CMP field to an entity bean, the IDE does the following:

To view or edit an existing CMP field:

  1. In the Projects window, expand the Configuration Files node for your EJB module project.
  2. Double-click ejb-jar.xml. The graphical editor opens in the Details view.
  3. Expand the header for the entity bean node and the CMP Fields header. The table lists all of the existing CMP fields.
  4. Click Add or Edit to make changes to the list of CMP fields.

Notes:

See Also
About Entity Beans
Creating an Enterprise Bean
Generating CMP Entity Beans from a Database
Defining a Select Method
Defining a Finder Method
Connecting to a Database
Obtaining a Database Schema

Legal Notices