Hi, I use optimistic lock to prevent concurrent update, configured like this: <class name="Cls" table="tbl" optimistic-lock="version" > ... <version name="version" column="version" /> <property name="created" column="createdTS" type="timestamp" generated="always" /> ...
But even if I only read the record the version number increased I read it like this for example:
Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); Criteria criteria =session.createCriteria(Cls.class); criteria.list(); session.getTransaction().commit();
What is wrong with my config or code? Why the version numbere incresed every time. Thank you.
|