• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

session.flush() vs. transaction.commit()

Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,

In Hibernate, what is actually the difference between session.flush() and transaction.commit()?

The online API does not really explain why we need them both. It seems to me like they do pretty much the same.

Look at this code, taken from The Hibernate Tutorial:

Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my current project at work, we don't work with Transactions directly; it is the application server which pretty much handles that for us. So calling is all we have to deal with.

In any case, they are intended to perform the same thing, namely synchronize. The description can be found in the section Flushing the Session of Hibernate Documentation.
The only cure for that is hours of television radiation. And this tiny ad:
the value of filler advertising in 2020
    Bookmark Topic Watch Topic
  • New Topic