@Test(expected = OptimisticLockException.class)
public void testManagedEntity() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
Company company = new Company();
company.setName("a");
s.save(company);
tx.commit();
tx = s.beginTransaction();
company.setName("b");
company.setVersion(company.getVersion() - 1); tx.commit();
s.close();
}