# Version mapping

Use a Version Mapping to specify the field used for optimistic locking. If the entity is associated with multiple tables, you should use a version mapping only with the primary table. You should have only a single version mapping per persistent entity. Version mappings may be used only with the following attribute types:

- `int`

- `Integer`

- `short, Short`

- `long, Long`

- `Timestamp`

To create a version 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 Version.

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

   Property | Description | Default
   --- | --- | ---

   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. This must be the primary table associated with the attribute's entity.

   - 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.

Eclipse adds the following annotations to the field:

    @Version
    @Column(table="<COLUMN_TABLE>", name="<COLUMN_NAME>", insertable=false,
        updatable=false)

Mapping an entity

Persistence Outline view
Persistence Properties view (for attributes)

Understanding OR mappings
Understanding JSR220: EJB 3.0