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.
Select the Employee entity in the Package Explorer view.
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.
In the Map As field, select ID.
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 |
Leave all other fields on the tab as their defaults. Expand the Primary Key Generation area.
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:
Repeat this procedure to map the following primary keys (as shown in Table: Tutorial Database Schema):
The id field of the Address entity to the ADDRESS_ID column of the ADDRESS table.
The number field of the PhoneNumber entity to the P_NUMBER column of the PHONE table.
Next, you will Create basic mappings.