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 Insert Code > Add CMP Field. This command is only enabled when you click within the body of the class (after the class declaration).
  3. 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 General view.
  3. Click the XML tab and make your changes in the XML editor.

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
Configuring EJB Deployment Descriptors
Connecting to a Database
Obtaining a Database Schema

Legal Notices