# ID mapping

Use an ID Mapping to specify the primary key of an entity. ID mappings may be used with a Persistent entity or Mapped superclass. Each Persistent entity must have an ID mapping.

1. In the Persistence Outline view, select the field to map. The Persistence Properties view (for attributes) displays the properties for the selected.

2. In the Map As field, select ID.

3. Use this table to complete the remaining fields on General tab in the Persistence Properties view.

   Property | Description | Default
   --- | --- | ---
   Map As | Defines this mapping as an ID Mapping. This field corresponds to the `@Id` annotation. | ID

   Column

   The database column (and its table) mapped to the entity attribute. See "Column" for details.

   - Name – Name of the database column.

   - Table – Name of the database table.

   - Insertable – Specify if the column is always included in `SQL INSERT` statements.

   - Updatable – Specify if the column is always included in `SQL UPDATE` statements.

   By default, the Column is assumed to be named identically to the attribute and always included in the `INSERT` and `UPDATE` statements.

   Temporal

   Specifies the type of data. See "Temporal" for details.

   - Date

   - Time

   - Timestamp

4. Use this table to complete the fields on PK Generation tab in the Persistence Properties view.

   Property | Description | Default
   --- | --- | ---
   Primary Key Generation | These fields define how the primary key is generated. |

   Strategy

   See "Primary Key Generation" for details.

   - Auto

   - Sequence

   - Identity

   - Table

   Auto

   Generator Name | Name of the primary key generator specified in the Strategy |

Additional fields will appear on the PK Generation tab, depending on the selected Strategy. See "Persistence Properties view (for attributes)" for additional information.

Eclipse adds the following annotations to the field:

    @Id
    @Column(name="<COLUMN_NAME>", table="<TABLE_NAME>", insertable=<INSERTABLE>,
        updatable=<UPDATABLE>)
    @Temporal(TemporalType.<TEMPORAL>)
    @GeneratedValue(strategy=GeneratorType.<STRATEGY>, generator="<GENERATOR_NAME>")@TableGenerator(name="<TABLE_GENERATOR_NAME>", table = "<TABLE_GENERATOR_TABLE>",
        pkColumnName = "<TABLE_GENERATOR_PK>",
        valueColumnName = "<TABLE_GENERATOR_VALUE_COLUMN>",
        pkColumnValue = "<TABLE_GENERATOR_PK_COLUMN_VALUE>")@SequenceGenerator(name="<SEQUENCE_GENERATOR_NAME>",
        sequenceName="<SEQUENCE_GENERATOR_SEQUENCE>")

Mapping an entity

Persistence Outline view
Persistence Properties view (for attributes)

Understanding OR mappings
Understanding JSR220: EJB 3.0