Quote:
I am doing optimistic concurreny check for this table through one timestamp field in the table. And this timestamp value, I am not changing while each updation of the record. I am keeping it same. Can that be causing this issue ? I mean if I make this timestamp field to be automatically generated at DB side while any modification, it might work out.
Mostly I don't use timestamps, but the specific <version> tag. Something along the lines of:
Code:
<class name="Category" table="CATEGORY" lazy="true">
<id name="id" column="CATEGORY_ID">
<generator class="native"/>
</id>
<!-- Versioned entity. -->
<version name="version" column="VERSION"/>
[rest of mapping]
And in the java code something like:
Code:
public class Category {
private Long id;
private int version;
The version is automatically updated by Hibernate. You don't have to touch it yourself. Everytime your object is saved, you should see in the database a version update.
If Hibernate finds a mismatch (because somebody else updated the row), Hibernate will throw the "StaleObjectStateException".
Regards,
Jos