As for the reference document automatic versioning is very useful in optimistic
concurrency control. Can anyone please explain how this autoatic versioning will
work for optimistic concurrency control?.
 
thanx
dosapati
----- Original Message -----
From: dosapati
Sent: Saturday, October 11, 2003 8:43 PM
Subject: [Hibernate] automatic versioning problem

hi,
 
I tried automatic versioning by using <version ....> tag in class mapping like
 
  <class name="persistence.BeanVersion" table="beanversion">
   <id name="id" unsaved-value="0" type="int">
      <generator class="identity"/>
    </id>
    <version column="version" name="version"/> /*VERSION TAG */
    <property name="name" type="string"/>
  </class>
 
I generated 'BeanVersion' class from the above mapping. I used that class in my code:
 
  BeanVersion bv = new BeanVersion();
  bv.setName("Entity-1");
  Session session = sessionFactory.openSession();
  session.save(bv);
 
After executing the above code, I expected the Hibernate would set the version as '1'
in the database. But the version in database was '0'.
 
  BeanVersion bv = (BeanVersion) session.load(BeanVersion.class, new Integer(id));
  bv.setName("entity changed");
  session.saveOrUpdate(bv);
 
In my second usecase, I am loading the instance and modifying the data in it ans calling saveOrUpdate()
method in it. The object version is not getting changed by Hibernate even after updating the entity details.
 
Am I missing anything? How do I achieve automatic versioning by Hibernate.
Please provide me if any posts or any examples are available.
 
I will be very thankful for your suggessions.
 
--
dosapati

Reply via email to