This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi, I have read chapter about using EntityManager in 'EJB 3.0 in Action' and I have some doubts about one thing. The authors wrote, that a way of getting the latest data from DB is to use refresh function (Refresh the state of the instance from the database, overwriting changes made to the entity, if any.). The parameter of this function is an object, which should be already attached to the EntityManager (EM), so we could write it like this:
Earlier the authors have already wrote, that functions connected to EM (like persist, merge and so on), don't have to be done right away, they will be done later or soner, but we can't be shure when (of course before transaction commit) - it's becaouse FlashMode is set to 'Auto'. So me questions is simple. Is it possible, that in
the 'inside' part of the function (entityManager.merge(item)), will be executed by the entitymanager so that it will send to DB some kind of new data connected with this entity (it will be flushed), and later the 'refresh' method will get this new data (which will be already in DB).
And, if no, what about this code:
I hope my questions is quite clear (if not sorry). Thanks a lot for the answers.
SCJP, SCWCD, OCUP
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Doubts about refresh + merge function in JPA