IntelliJ IDEA 2017.1 Help

Creating CMP Bean Fields

This feature is supported in the Ultimate edition only.

CMP fields are used to provide persistence of the entity beans. Being created, a CMP field appears in the deployment descriptor, and its accessor methods are added to the entity bean classes. So doing, IntelliJ IDEA provides gutter icons in the editor that help you jump from a CMP field declaration in the deployment descriptor to the accessor methods in the bean class, and vice versa:

/help/img/idea/2017.1/cmpField4.png
/help/img/idea/2017.1/cmpField5.png

IntelliJ IDEA enables you to create CMP fields in several ways:

To create a CMP field by editing the source code

  1. Open the deployment descriptor file ejb-jar.xml for editing.
  2. In the entity section for the corresponding entity bean, type the tags for CMP fields, and specify their names.
  3. Open the source code of the desired entity bean class for editing. The code inspection detects missing accessor methods:
    /help/img/idea/2017.1/cmpField1.png
  4. Press Alt+Enter to reveal the list of suggested quick fixes:
    /help/img/idea/2017.1/cmpField2.png
  5. Create getter and setter methods in the bean implementation class.
  6. If you want to make the new CMP field a primary key, add the <primkey-field> entry to the deployment descriptor.

To create a CMP field

  1. In the EJB tool window, right-click the desired entity bean.
  2. On the context menu, click New, and then choose CMP field on the submenu.
    /help/img/idea/2017.1/cmpField3.png
  3. In the Create CMP Field dialog box, specify the following parameters:
    • Field name, optional description and type. You can choose the desired type from the drop-down list, or click the ellipsis button and select type from the Choose CMP Field Class dialog box.
    • Whether the new CMP field will be a primary key. Select the Primary key check box, if you want to make this field a primary key.
    • Whether the accessor methods will be generated in the local and remote interfaces. If you select the corresponding check boxes, the getter and setter methods will be created in the local and remote interfaces, in addition to the bean class.
  4. Click OK.

See Also

Last modified: 18 July 2017