Skip to content

Conversation

@HyunSangHan
Copy link
Contributor

JdbcTemplate::queryForStream used in try-with-resources blocks causes database connections to close prematurely, leading to DataAccessResourceFailureException: This connection has been closed when Hibernate transactions are still active.

The queryForStream() method sets up an onClose() callback that immediately releases the database connection when the Stream is closed, but Hibernate transactions may still need to use the same connection, causing a lifecycle mismatch.

I replaced queryForStream with query in all affected JDBC DAO classes.

Resolves #5006

@HyunSangHan
Copy link
Contributor Author

HyunSangHan commented Oct 1, 2025

Oh, I'll rebase and push it soon. It's from outdated main branch 😢
I did it.

@fmbenhassine
Copy link
Contributor

Thank you for the PR! However, I prefer reverting the commit that introduced the regression (to trace the source of the problem) rather than adding a new commit that might fix the regression in a different way (Note for example this PR does not revert the changes related to JdbcJobExecutionDao introduced in b88e7d7).

I already reverted the problematic commit, hence I am closing this PR.

Thank you anyway for your time and effort 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Jdbc Hibernate Connection closed prematurly when launching a Job

2 participants