Guest User

Untitled

a guest
Mar 17th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. MyEntity e = new MyEntity();
  2.  
  3. // scenario 1
  4. // tran starts
  5. em.persist(e);
  6. e.setSomeField(someValue);
  7. // tran ends, and the row for someField is updated in the database
  8.  
  9. // scenario 2
  10. // tran starts
  11. e = new MyEntity();
  12. em.merge(e);
  13. e.setSomeField(anotherValue);
  14. // tran ends but the row for someField is not updated in the database (you made the changes *after* merging
  15.  
  16. // scenario 3
  17. // tran starts
  18. e = new MyEntity();
  19. MyEntity e2 = em.merge(e);
  20. e2.setSomeField(anotherValue);
  21. // 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