em.getTransaction().commit();
em.getTransaction().begin();
lock = em.getReference( Lock.class, lock.getId() );
Integer version = lock.getVersion();
em.lock( lock, LockModeType.WRITE );
em.getTransaction().commit();
em.getTransaction().begin();
lock = em.getReference( Lock.class, lock.getId() );
try {