user454696
user454696

Reputation: 69

function of getHibernateTemplate().flush()

I am new to Hibernate. Please tell me what is the use of getHibernateTemplate().flush() and how it works.

Upvotes: 1

Views: 3872

Answers (1)

Pascal Thivent
Pascal Thivent

Reputation: 570505

When using Hibernate, entities are loaded into a persistence context called the session and changes like creating, updating, deleting persistent objects are actually made in memory. When you want or need to synchronize the in memory state with the database to make changes persistent, you need to flush the session, causing Hibernate to generate the appropriate SQL insert, update, delete statements.

Upvotes: 2

Related Questions