Reset autocomit fails when AFTER_TRANSACTION release mode

I’m using Hibernate 5.0.12.
In, afterCompletion() method is called after a commit.

	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.

The source code has changed anyway, so try with Hibernate 5.3 or 5.2 and see if it works better for you.

Hibernate 5.0 is a rather old branch and not actively maintained, so you need to upgrade to a newer version.