On commit, Hibernate reopens and closes additional connection

Description

When running in standalone (non JEE) environment with the default Hibernate configuration, I'm seeing this behavior regarding Hibernate's use of underlying DataSource's connections:
commit() will commit and close the JDBC connection, then it will reopen it, set it to autocommit false and close it immediately.

I instrumented DataSource and Connection classes to print when their methods are called.

Here is the full code:

And here is the full output:

Environment

None

Status

Assignee

Vlad Mihalcea

Reporter

Alon

Fix versions

Labels

None

backPortable

Backport?

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure