Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MyEntity e = new MyEntity();
- // scenario 1
- // tran starts
- em.persist(e);
- e.setSomeField(someValue);
- // tran ends, and the row for someField is updated in the database
- // scenario 2
- // tran starts
- e = new MyEntity();
- em.merge(e);
- e.setSomeField(anotherValue);
- // tran ends but the row for someField is not updated in the database (you made the changes *after* merging
- // scenario 3
- // tran starts
- e = new MyEntity();
- MyEntity e2 = em.merge(e);
- e2.setSomeField(anotherValue);
- // tran ends and the row for someField is updated (the changes were made to e2, not e)
Add Comment
Please, Sign In to add comment