• 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

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

 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic