10.3. Timestamp
<div class="paragraph">
Timestamps are a less reliable way of optimistic locking than version numbers, but can be used by applications for other purposes as well.
Timestamping is automatically used if you the `@Version` annotation on a `Date` or `Calendar` property type.
</div>
<div id="locking-optimistic-version-timestamp-example" class="exampleblock">
<div class="title">Example 277. Using timestamps for optimistic locking</div>
<div class="content">
<div class="listingblock">
<div class="content">
<pre class="prettyprint highlight">`@Version
private Date version;`</pre>
</div>
</div>
</div>
</div>
<div class="paragraph">
Hibernate can retrieve the timestamp value from the database or the JVM, by reading the value you specify for the `@org.hibernate.annotations.Source` annotation.
The value can be either `org.hibernate.annotations.SourceType.DB` or `org.hibernate.annotations.SourceType.VM`.
The default behavior is to use the database, and is also used if you don’t specify the annotation at all.
</div>
<div class="paragraph">
The timestamp can also be generated by the database instead of Hibernate, if you use the `@org.hibernate.annotations.Generated(GenerationTime.ALWAYS)` annotation.
</div>
</div>
<div class="sect2">