Create ID mappings

Use an ID Mapping to specify the primary key of an entity. Each persistent entity must have an ID. Notice that the Problems view reports that each entity is missing an ID.

  1. Select the Employee entity in the Package Explorer view.

  2. Expand the Employee entity in the JPA Structure view and select the id field. The JPA Details view (for attributes) displays the properties for the field.

  3. In the Map As field, select ID.

    ID Mapping for emp_id Field

    JPA Details view for the emp_id field.
  4. Use this table to complete the remaining fields in the JPA Details view.

    Property Description
    Map As Defines this mapping as an ID Mapping. Dali adds the @Id annotation to the entity.
    Column The database column for the primary key of the table associated with the entity. Select EMP_ID.

    Because the database column (EMP_ID) is named differently than the entity field (id), Dali adds the @Column(name="EMP_ID") annotation.


  5. Leave all other fields on the tab as their defaults. Expand the Primary Key Generation area.

    Primary Key Generation for emp_id Field

    JPA Details view (with Primary Key options) for the emp_id field.
  6. Use this table to complete the Primary Key Generation fields in the JPA Details view.

    Property Description
    Generated Value These fields define how the primary key is generated.
      Strategy For the tutorial project, use the Auto option.
      Generator Name Leave this field blank.

In the JPA Structure view, the id field is identified as the primary key by the following icon:

JPA Structure for Employee Entity

emp_id attribute of the Employee entity in the JPA Structure view.

Repeat this procedure to map the following primary keys (as shown in Table: Tutorial Database Schema):

Next, you will Create basic mappings.