Skip to content
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

Hibernate Query.list() is not included in SharedEntityManagerCreator's queryTerminatingMethods set, causing DB connection not to be released when query is proxied #23248

Closed
wcandml opened this issue Jul 8, 2019 · 3 comments
Assignees
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement
Milestone

Comments

@wcandml
Copy link

wcandml commented Jul 8, 2019

The queryTerminatingMethods of the SharedEntityManagerCreator class does not contain the "list" method:

image-2019-07-06-14-41-13-148

In the DeferredQueryInvocationHandler class, when the EntityManager is closed, it is determined whether the method name is in "queryTerminatingMethods":

image-2019-07-06-14-43-21-734

When org.hibernate.query.Query.list() is used, and QueryImpl and NativeQueryImpl are delegated by DeferredQueryInvocationHandler, the database connection is not released:

image-2019-07-06-14-56-26-274

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jul 8, 2019
@sbrannen
Copy link
Member

sbrannen commented Jul 8, 2019

Since org.hibernate.Query.list() is effectively an alias for javax.persistence.TypedQuery.getResultList() (which is in the queryTerminatingMethods set), why don't you just switch to using getResultList() instead of list()?

@sbrannen sbrannen added in: data Issues in data modules (jdbc, orm, oxm, tx) status: waiting-for-feedback We need additional information before we can continue labels Jul 8, 2019
@sbrannen sbrannen changed the title The org.hibernate.query.Query.list() method is not included in the org.springframework.orm.jpa.SharedEntityManagerCreator.queryTerminatingMethods collection, which causes the database connection to be unreleased when the query is proxied. Hibernate Query.list() is not included in SharedEntityManagerCreator.queryTerminatingMethods set, causing database connection not to be unreleased when query is proxied Jul 8, 2019
@jhoeller jhoeller self-assigned this Jul 8, 2019
@jhoeller jhoeller added type: enhancement A general enhancement and removed status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged or decided on labels Jul 8, 2019
@jhoeller jhoeller added this to the 5.1.9 milestone Jul 8, 2019
@jhoeller
Copy link
Contributor

jhoeller commented Jul 8, 2019

Generally the JPA getResultList method should be used there, indeed... but it doesn't hurt to add Hibernate's list() variant as well. I'll add it for 5.1.9.

@wcandml
Copy link
Author

wcandml commented Jul 9, 2019

@sbrannen Yes, I can replace list with getResult, but you can't stop others from using list, so i agree with @jhoeller ,add list to avoid this problem .Thanks @sbrannen and @jhoeller .

@sbrannen sbrannen changed the title Hibernate Query.list() is not included in SharedEntityManagerCreator.queryTerminatingMethods set, causing database connection not to be unreleased when query is proxied Hibernate Query.list() is not included in SharedEntityManagerCreator's queryTerminatingMethods set, causing DB connection not to be released when query is proxied Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants