@Test public void testPessimisticRead() { String name = "pessimisticRead"; long id = createUser(name); EntityManager em = factory.createEntityManager(); EntityTransaction tx = em.getTransaction(); tx.begin(); User u1 = em.find(User.class, id, LockModeType.PESSIMISTIC_READ); assertNotNull(u1); TransactionExecutor executor = new TransactionExecutor(factory); executor.syncExe(s -> { User user = s.find(User.class, id); String readName = user.getName(); }); tx.commit(); em.close(); }
public String getName() { return name; }
User { public String getName() { return name; } }
User { public String getName() { return name; } User(); }
User { public String getName() { return name; } User(); Long getId(); void setId(Long id); String getName(); void setName(String name); Integer getVersion(); void setVersion(Integer version); }
User { public String getName() { return name; } User(); Long getId(); void setId(Long id); String getName(); void setName(String name); Integer getVersion(); void setVersion(Integer version);  }