Similar to the issue https://github.com/spring-projects/spring-framework/issues/23248
The org.springframework.orm.jpa.SharedEntityManagerCreator.queryTerminatingMethods
does not contain the "uniqueResult" method:
When the EntityManager is closed and org.hibernate.query.Query.uniqueResult()
is used, as QueryImpl is delegated by DeferredQueryInvocationHandler, the database connection could not be released:
Seems uniqueResult
might not be used here, but add this could prevent this issue as it could not stop developers to use uniqueResult
.
Would it be possitble to add uniqueResult
?
Comment From: sbrannen
Indeed, this is very similar to #23248 and therefore seems like a reasonable enhancement.
Though, if we're going to support Hibernate's list()
and uniqueResult()
methods, I think we should probably go ahead and support the following as well.
uniqueResultOptional()
stream()
@jhoeller, thoughts?
Comment From: jhoeller
Indeed, it does not hurt to aim for complete coverage of Hibernate's query execution methods there. Since the aforementioned methods all seem to be present in Hibernate ORM 5.6 already, we should also backport this to Spring Framework 5.3.26.
Comment From: sbrannen
This has been addressed as described in commit 57fb0722154696474e3b47911a4cbd491451fda8 for inclusion in 6.0.5
and backported to 5.3.26
in commit 3d6d853bbc99d2321a46385466e0150885b9f4bb.