• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Doubts about refresh + merge function in JPA

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Willie Smits increased rainfall 25% in three years by planting trees. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic