Skip to content

ResultSet holdability into the View layer broken by Hibernate 5 #26557

@symposion

Description

@symposion

Some time ago a fix was introduced for this: #16954 . It allows specifying that ResultSets should be held open beyond transaction commit. (Separate problem: there's no easy way to do this for JPATransactionManager, which makes usage with Spring Data hard). In the meantime, however, changes made in Hibernate 5 have re-broken this functionality. Hibernate now aggressively closes all JDBC resources on transaction commit, and the Hibernate maintainers have basically said that cursor holdability is evil and they're not interested in supporting it (https://discourse.hibernate.org/t/resultset-holdability-not-working-with-hibernate/1445/9)

As things stand, this makes it pretty much impossible (AFAICT) to build a fully streaming stack from database to MVC layer (using Open Session In View) - in particular a streaming REST API that returns a stream of JSON objects from a large dataset. It also renders HibernateTransactionManager.allowResultSetAccessAfterCompletion pointless because Hibernate closes the result set anyway, irrespective of the behaviour of the underlying JDBC driver.

It's not clear to me if there's a viable solution for any of this, but as a minimum it would be great if this was clearly documented as a limitation. I've spent hours wandering through issues, forum posts + SO answers getting conflicting information about this and it would be good to have a definitive statement of what is and isn't possible in this regard

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)status: backportedAn issue that has been backported to maintenance branchestype: documentationA documentation task

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions