-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ResultSet holdability into the View layer broken by Hibernate 5 #26557
Comments
I've run into this very problem today when some code started exhibiting It looks like it is then trying to lazy-load those fields, but it can't because the transaction (and thus the connection and its result set) is already closed.
I guess one potential workaround would be to grab the ObjectMapper and serialize the object graph first, but of course this wouldn't work well for very large object graphs. Update: I discovered that in our case it wasn't what I thought it was: there was some wrongful interplay between a custom Hibernate Persister and a service into which it called that was annotated with |
Reading up on the current state of affairs, it seems appropriate to deprecate |
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
The text was updated successfully, but these errors were encountered: