• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

flush() Vs refresh()

 
Mahendar Reddy
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends...

As I know 'EntityManager.flush()' method synchronizes the persistence context with the underlying database and 'EntityManager.refresh()' method refresh the state of the entity.

What does it exactly mean by synchronizing the persistence context with the underlying database? doesn't it update the state of all entities in that persistent context?

Thanks in advance....




 
Morten Franorge
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm pretty sure this is how it is:

flush() forces a database update for all created, updated and deleted entities in the entityManager.

refresh() refreshes the state of all entities managed by the entitymanager. overwriting changes that hasn't yet been written to database (by a flush call etc)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic