Timestamp in hibernate with database by R4R Team

In hibernate <timestamp> element contains the timestamped data. <timestamp> provides alternative to versioning. Timestamp used to less safe implementation of optimistic locking. Hibernate application might use the timestamp in the other ways.


<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|." />


Tag

Description

column(optional)

It found defaults to the property name.

We can say that name of a column holding the timestamp.

Name

It means name of a JavaBeans style property of java type dat or timestamp of the persistent class.

access(optional)

It set defaults on the property.

In the hibernate application strategy hibernate uses for accessing the property value.

Unsaved-value(optional)

Defaults to null.

Here a version property value that indicate that an instance is newly instantiated (unsaved), distinguishing it from detached instances that were saved or loaded i a previous session. Undefined specifies that the identifer property value should be used.

source(optional)

We found this defaults on vm.

In the hibernate retrieve the timestamp value from? It means the database or the from current jvm can find the value. Databased timestamp incur an overhead because hibernate must hit the database in order to determine the “next value”. It is safer to use in clustered environments. Not all dialects are known to support the retrieval of the database current timestamp.

generated(optional)

It can't set on defaults.

It specifies that this timestamp property value is actually generated by the database.


We found some imporatant points to remember which is given below:

<Timestamp> is equivalent to <version type="timestamp"> And 

<timestamp source="db"> is equivalent to <version type="dbtimestamp">

Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!