I think Java Persistence With Hibernate has a mistake on p423. It has a code sample that looks something like:
Code:
EntityManager em = emf.createEntityManager();
EntityTransaction tx = em.getTransaction();
tx.begin();
Item item = em.find(Item.class, new Long(1234));
tx.commit();
item.setDescription(...);
tx.begin();
User user = em.find(User.class, new Long(3456));
user.setPassword("secret");
tx.commit();
em.close();
And then it says:
Quote:
...in the second transaction, you not only load a User object, but also update the modified persistent item when the second transaction is committed (in addition to an update for the dirty
user instance).
But item.setDescription(...) is not called within the second transaction in the example code, item.setDescription(...) should be moved one line down. Is this correct?