I have an entity:
<class name="name.dargiri.model.Entity" table="ENTITY" optimistic-lock="version">
<version name="version" column="ver" type="long" />
</class
If Entity is saved no matter how many times, at the end of the transaction, Hibernate selects the version of the object. What for? Hibernate generates this version when it stores an object, so it knows that. I found out that this method calls this:
EntityVerifyVersionProcess
Sleep mode generates this in the logs:
Hibernate:
/* update
name.dargiri.model.Entity */ update
ENTITY
set
ver=?,
USERNAME=?,
lucky_number=?
where
id=?
and ver=?
Hibernate:
/* get version name.dargiri.model.Entity */ select
ver
from
ENTITY
where
id =?
I am using MySQL and Session # save ().
source
share