I’m using Hibernate 5.0.12.
In LogicalConnectionManagedImpl.java, afterCompletion() method is called after a commit.
@Override
protected void afterCompletion() {
afterTransaction(); (1)
resetConnection( initiallyAutoCommit ); (2)
initiallyAutoCommit = false;
}
(1) - release the current connection because AFTER_TRANSACTION
(2) - get a connection, which could be the previous connection or new one, and reset autocommit.
If the reset connection is new one, the previous connection’s autocommit is true and keep the same value before closed.
Since Hibernate set the autocomit = false when transaction begin, every connection should be reset to initial value by Hibernate.