Skip to content

Session.close() accidentally triggers creation of TransactionAwareDataSourceProxy Connection #23346

Closed
@jpozorio

Description

@jpozorio

Affects: 3.1.4.RELEASE
Using hibernate: 3.6.10.Final


I'm facing an issue caused by opening connections with database on session.close call.
For some reason, hibernate throws an exception when is opening a connection with database, then he starts to rollback the transaction.
From now on, a proxy connection exists in session (TransactionAwareInvocationHandler), but real connection with database does not exists.

After that, spring-orm call SessionFactoryUtils.closeSession, and this goes to close connection, but real connection failed to be created

Hibernate ConnectionManager, before close the connection call JDBCExceptionReporter.logAndClearWarnings( connection ); (connection parameter is proxy TransactionAwareInvocationHandler connection without real connection because creation failed)

Then TransactionAwareInvocationHandler create a new connection with database because getWarnings and clearWarnings are not mapped methods in invoke
This connection is closed right after creation, but when I am inside a transaction, this connection resource is binded to thread and never unbinded. Because spring-tx is alredy in a rollback block.

I think a connection should not be opened when some of those two methods getWarnings and clearWarnings are called and real connection does not exists.

zgsolucoes@35c0b08

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions