This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Doubt Regarding Transaction and flush Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Doubt Regarding Transaction and flush" Watch "Doubt Regarding Transaction and flush" New topic

Doubt Regarding Transaction and flush

vipul bondugula
Ranch Hand

Joined: Oct 14, 2010
Posts: 218
Hi ,

I am novice in hibernate. i am having a doubt regarding transactions and flushing..

whenever we want to persist an object we open a session and begin a transaction. after persisting which one of these comes first and the other follows ......


According to what i have read commit() commits values to the database.
flush() syncs objects state to the database.

what is the difference between these two.....

Thanks & Regards,
vipul kumar.

Vipul Kumar
Vijitha Kumara

Joined: Mar 24, 2008
Posts: 3816

It is called during a commit as well, but there can be other scenarios where flush() is required as described here.

[How to ask questions] [Twitter]
subject: Doubt Regarding Transaction and flush
Similar Threads
CMP Transactions Doubt
Doubt in Session beans
Entity Manager flush() doubt
Entitymanager.refresh doubt