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:
- Open the bean class in the Source Editor.
- 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).
- 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:
- Adds the get and set methods for the field to the bean class.
- Registers the CMP field in the deployment descriptor.
To view or edit an existing CMP field:
- In the Projects window, expand the Configuration Files node for your EJB module project.
- Double-click ejb-jar.xml. The graphical editor opens in the General view.
- Click the XML tab and make your changes in the XML editor.
- If you make changes to CMP fields in ejb-jar.xml you will
also need to make corresponding changes in your bean source code.
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