29. Legacy Domain Model
Example 698. Declaring a version property in hbm.xml
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
-->
<version
column="version_column"
name="propertyName"
type="typename"
access="field|property|ClassName"
unsaved-value="null|negative|undefined"
generated="never|always"
insert="true|false"
node="element-name|@attribute-name|element/@attribute|."
/>
column | The name of the column holding the version number. Optional, defaults to the property name. |
name | The name of a property of the persistent class. |
type | The type of the version number. Optional, defaults to |
access | Hibernate’s strategy for accessing the property value. Optional, defaults to |
unsaved-value | Indicates that an instance is newly instantiated and thus unsaved. This distinguishes it from detached instances that were saved or loaded in a previous session. The default value, |
generated | Indicates that the version property value is generated by the database. Optional, defaults to |
insert | Whether or not to include the |
Example 699. The timestamp element in hbm.xml
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
-->
<timestamp
column="timestamp_column"
name="propertyName"
access="field|property|ClassName"
unsaved-value="null|undefined"
source="vm|db"
generated="never|always"
node="element-name|@attribute-name|element/@attribute|."
/>
column | The name of the column which holds the timestamp. Optional, defaults to the property name |
name | The name of a JavaBeans style property of Java type |
access | The strategy Hibernate uses to access the property value. Optional, defaults to |
unsaved-value | A version property which indicates that the instance is newly instantiated and unsaved. This distinguishes it from detached instances that were saved or loaded in a previous session. The default value of |
source | Whether Hibernate retrieves the timestamp from the database or the current JVM. Database-based timestamps incur an overhead because Hibernate needs to query the database each time to determine the incremental next value. However, database-derived timestamps are safer to use in a clustered environment. Not all database dialects are known to support the retrieval of the database’s current timestamp. Others may also be unsafe for locking because of lack of precision. |
generated | Whether the timestamp property value is generated by the database. Optional, defaults to |