Flushing the Session gets the data that is currently in the session synchronized with what is in the database.
More on the Hibernate website:
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()
.