-
Notifications
You must be signed in to change notification settings - Fork 623
Closed
Milestone
Description
When using Hibernate as the Persistence provider for Jakarta Data the following error can occur:
org.hibernate.sql.exec.ExecutionException: A problem occurred in the SQL executor : Error advancing (next) ResultSet position [DSRA9110E: ResultSet is closed.]
Reason: When Hibernate returns a stream of data, the stream is backed by the JDBC ResultSet and a Spliterator. When the operation is executed outside a transaction, Hibernate closes the connection before returning the stream. Therefore, making streams unusable outside of a transaction.
Documentation: https://jakarta.ee/specifications/persistence/3.2/apidocs/jakarta.persistence/jakarta/persistence/query#getResultStream()
Which allows implementations to have custom behavior
Resolution: Likely the best way to handle this would be to detect if we are in a transaction:
- if so, request a stream, then return that stream
- if not, request a list, then return the stream. (default behavior)
Testing:
- I was able to work around this issue by surrounding the repository method call with
tran.begin()andtran.commit() - I was unable to work around this issue by annotating the repository method call with
@Transactional
Metadata
Metadata
Assignees
Labels
No labels