I have a requirement that once the entity is persisted, the new version value must be returned back to the client side in order to prevent concurrency issues in future calls.
Code:
Employee emp1 = dao.findById(new Short((short) 13));
emp1.setCity("cmb");
EntityManagerHelper.beginTransaction();
System.out.println(emp1.getVersion());
Employee updatedEmp = dao.update(emp1);
System.out.println(updatedEmp.getVersion());
EntityManagerHelper.commit();
However, I found that when the version value is retrieved from the returned object of Hibernate update/merge operation, it is not incremented. Is there a way to get the updated version value as part of the update operation?