Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate: flush() does not commit to database

 
kurt hanni
Ranch Hand
Posts: 140
Eclipse IDE Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I'm using hibernate 3.0 & mysql5, I'm following the samples in "Hibernate quickly".

when I use flush() to save a record it doesn't reflect in the database(MySql)?


but it works if I use transaction.commit()



Why does flush doesn't work for me, do I have to configure something in hibernate? or am I doing something wrong?

Thanks
 
John Grath
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Flush should write to the database. However, if your code is running in a transaction nothing will be committed to the database until the transaction performs a commit. This is correct behaviour.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See this - a good Wiki entry that covers transactional behaviour, Hibernate and why it doesn't use the auto-commit behaviour common in some SQL clients.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic