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 Persistence Outline view and select the id field. The Persistence Properties view (for attributes) displays the properties for the field.

  3. In the Map As field, select ID.

    ID Mapping for emp_id Field

    This figure shows the Persistence Properties page for the emp_id field.
  4. Use this table to complete the remaining fields on the Persistence Properties view.

    Property Description
    Map As Defines this mapping as an ID Mapping. Dali adds the @Id annotation to the entity.
    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.
    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.


In the Persistence Outline, the id field is identified as the primary key by the following icon:

Persistence Outline for Employee Entity

This figure shows the emp_id attribute of the Employee entity in the Persistence Outline view.

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

Next, you will Create basic mappings.