What is the reason for this behavior?
If for some reason I perform two suitable operations outside the transaction (not recommended, I know!), And I set Hibernate to automatically reset, I would expect it to automatically reset if the second operation is such (for example, list, iterateor executeUpdate).
What will happen if not for explicitly checking the second line of the method autoFlushIfRequried:
protected boolean autoFlushIfRequired(Set querySpaces) throws HibernateException {
errorIfClosed();
if ( ! isTransactionInProgress() ) {
return false;
}
AutoFlushEvent event = new AutoFlushEvent(querySpaces, this);
AutoFlushEventListener[] autoFlushEventListener = listeners.getAutoFlushEventListeners();
for ( int i = 0; i < autoFlushEventListener.length; i++ ) {
autoFlushEventListener[i].onAutoFlush(event);
}
return event.isFlushRequired();
}
Refresh . Thanks axtavt for finding the hibernation problem that caused this change (in 3.2): FlushMode.AUTO - > COMMIT if out of transaction .
: IDENTITY FlushMode.MANUAL/NEVER, : " , FlushMode.AUTO - ".