HHH-5205 Updated documentation about @Source

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@20742 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Hardy Ferentschik 2010-09-28 16:39:06 +00:00
parent 7419fc298d
commit 5fc7e88533
1 changed files with 15 additions and 4 deletions

View File

@ -2203,8 +2203,8 @@ public class Flight implements Serializable {
<title>Timestamp</title>
<para>Alternatively, you can use a timestamp. Timestamps are a less
safe implementation of optimistic locking. However, sometimes the
application might use the timestamps in other ways.</para>
safe implementation of optimistic locking. However, sometimes an
application might use the timestamps in other ways as well.</para>
<para>Simply mark a property of type <classname>Date</classname> or
<classname>Calendar</classname> as
@ -2217,8 +2217,19 @@ public class Flight implements Serializable {
public Date getLastUpdate() { ... }
} </programlisting>
<para>Like version numbers, the timestamp can be generated by the
database instead of Hibernate. To do that, use
<para>When using timestamp versioning you can tell Hibernate where to
retrieve the timestamp value from - database or JVM - by optionally
adding the <classname>@org.hibernate.annotations.Source</classname>
annotation to the property. Possible values for the value attribute of
the annotation are
<classname>org.hibernate.annotations.SourceType.VM</classname> and
<classname>org.hibernate.annotations.SourceType.DB</classname>. The
default is <classname>SourceType.DB</classname> which is also used in
case there is no <classname>@Source</classname> annotation at all.
</para>
<para>Like in the case of version numbers, the timestamp can also be
generated by the database instead of Hibernate. To do that, use
<code>@org.hibernate.annotations.Generated(GenerationTime.ALWAYS).</code></para>
<para>In hbm.xml, use the <literal>&lt;timestamp&gt;</literal>