atripathi
atripathi

Reputation: 908

Which FlushMode in Hibernate commits when you call session.flush()?

I read that whether a call to session.flush() commits or not depends on the FlushMode that is set. However, I don't know which FlushMode does this. I want the session to be flushed and commited. Which FlushMode should I use?

Upvotes: 0

Views: 3045

Answers (2)

bvanvelsen - ACA Group
bvanvelsen - ACA Group

Reputation: 1751

It's the other way around. you can flush when calling commit. These are the flushmodes in Hibernate: FlushModes

ALWAYS

The Session is flushed before every query.

AUTO

The Session is sometimes flushed before query execution in order to ensure that queries never return stale state.

COMMIT

The Session is flushed when Transaction.commit() is called.

MANUAL

The Session is only ever flushed when Session.flush() is explicitly called by the application.


I think you are looking for AUTO. So the session is flushed on Commit

Upvotes: 2

Stanislav Bashkyrtsev
Stanislav Bashkyrtsev

Reputation: 15308

I'd say vice versa - whether Hibernate flushes or not on commit depends on FlushMode.

Upvotes: 0

Related Questions