In Hibernate there is a technique integrated called "Managed Versioning".
For this purpose you need to add to your mapping hbm.xml-files following line beneath the </id> tag:
Code:
<version name="hbversion" column="hbversion" />
Don't forget a column in your regarding table with that name.
You also need a deklaration in your mapping class
Code:
int hbversion;
..and of course a getter and setter method.
Everytime you update an entity, hibernate adds to the update statement someting as WHERE hbversion=2 (suggesting that 2 was the version when you read the entity).
After updating hibernate checks the returned 'effected-rows' value and if it's zero, then an exception will be thrown: StaleObjectStateException. With this Exception you get the information, that a different transaction already updates the entity.
I hope you get what I meant and I told it exactly ;)
best regards