What's the use of session.flush() in Hibernate

后端 未结 9 1179
甜味超标
甜味超标 2020-11-28 01:38

When we are updating a record, we can use session.flush() with Hibernate. What\'s the need for flush()?

9条回答
  •  天涯浪人
    2020-11-28 01:57

    Flushing the Session gets the data that is currently in the session synchronized with what is in the database.

    More on the Hibernate website:

    • http://docs.jboss.org/hibernate/core/3.3/reference/en/html/objectstate.html#objectstate-flushing

    flush() is useful, because there are absolutely no guarantees about when the Session executes the JDBC calls, only the order in which they are executed - except you use flush().

提交回复
热议问题