This annotation specifies the version field or version property used to make use of the optimistic lock functionality.
The following types are supported by the version field or version property:
- int
- java.lang.Integer
- short
- java.lang Short
- long
- java.lang Long
- java.sql.Timestamp
Make note of the following points when using this annotation:
- You cannot specify @Version and @Temporal concurrently. Specify either of these annotations.
- Do not specify the version property in a table other than the primary table.
- In some applications, the field or property specified in @Version must not be updated.
- For bulk update, when multiple records are updated at once using SQL, the version field or version property is not updated automatically. Therefore, when you use the optimistic lock for performing bulk update, you must reference and update manually.
- You can set up only a single version field or version property for an entity class. If you set up multiple version fields or version properties, only a single will be enabled. The sequence for enabling the settings is not fixed.
The applicable targets are method and field.