Package jakarta.persistence
Annotation Interface Version
Specifies the version field or property of an entity class that
is used to detect optimistic lock failures. The version is used
to ensure integrity when performing the merge operation and for
optimistic concurrency control.
There should be no more than one Version
property or
field per class; entities with more than one Version
property or field are not portable.
The Version
property should be mapped to the primary
table for the entity class; entities that map the Version
property to a table other than the primary table are not portable.
The version property should have one of the following types:
int
, Integer
, short
, Short
,
long
, Long
, java.sql.Timestamp
,
Instant
, LocalDateTime
.
Example:
@Version
@Column(name = "OPTLOCK")
protected int getVersionNum() { return versionNum; }
- Since:
- 1.0