Thanks Shanta,
I am checking for versionging. Here is how i am using .but it is not updating the database.I am trying to use the same persistant instance to check how th versioning works with multiple Hibernate sessions.
Any more additions for checking ?.
Code:
Session session = HibernateSessionFactory.getInstance().getHibernateSession();
department = (Department)session.createCriteria(Department.class)
.add(Expression.eq("deptId",new Long("3")))
.uniqueResult();
session.close();
Session session2 = HibernateSessionFactory.getInstance().getHibernateSession();
Department department2 = (Department)session2.createCriteria(Department.class)
.add(Expression.eq("deptId",new Long("3")))
.uniqueResult();
department2.setDeptName("LOGISTICS");
Transaction transaction = session2.beginTransaction();
session2.saveOrUpdate(department2);
transaction.commit();
session2.close();
department.setDeptName("ACCOUNTS");
Session session3 = HibernateSessionFactory.getInstance().getHibernateSession();
Transaction transaction2 = session3.beginTransaction();
session3.lock(department,LockMode.READ);
session3.saveOrUpdate(department);
transaction2.commit();
session3.close();