tags:

views:

134

answers:

2

Have gone through hibernate api specification on FlushMode but didn't get the exact difference. So please help.

+1  A: 

Always means that before any query is run on a collection or such the query is rerun against the database. With auto I am assuming there is some "magic" under the hoods that knows most data doesn't change that often so you don't always have to flush. It also affects how often might happen during a transaction. I say might because some sources say setting the flushmode is only a hint to hibernate - but see this thread for some discussion...

http://forum.springsource.org/archive/index.php/t-14044.html

TheSteve0
+1  A: 

If flush mode is 'AUTO' before firing any query hibernate will check if there are any tables to be updated. If so, flush will be done otherwise no. If flush mode is 'ALWAYS', flush will happen even if there are no tables to be updated.

Check source of , org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(AutoFlushEvent)

Adi