diff --git a/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/internal/AbstractLoadPlanBasedLoader.java b/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/internal/AbstractLoadPlanBasedLoader.java index 939fe35df6..9720f31ffe 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/internal/AbstractLoadPlanBasedLoader.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/internal/AbstractLoadPlanBasedLoader.java @@ -24,6 +24,7 @@ import org.hibernate.dialect.pagination.LimitHandler; import org.hibernate.dialect.pagination.LimitHelper; import org.hibernate.dialect.pagination.NoopLimitHandler; import org.hibernate.engine.jdbc.ColumnNameCache; +import org.hibernate.engine.jdbc.spi.JdbcCoordinator; import org.hibernate.engine.jdbc.spi.JdbcServices; import org.hibernate.engine.jdbc.spi.ResultSetWrapper; import org.hibernate.engine.spi.PersistenceContext; @@ -37,6 +38,7 @@ import org.hibernate.internal.CoreMessageLogger; import org.hibernate.loader.plan.exec.query.spi.NamedParameterContext; import org.hibernate.loader.plan.exec.spi.LoadQueryDetails; import org.hibernate.loader.spi.AfterLoadAction; +import org.hibernate.resource.jdbc.ResourceRegistry; import org.hibernate.transform.ResultTransformer; import org.hibernate.type.Type; @@ -137,12 +139,14 @@ public abstract class AbstractLoadPlanBasedLoader { } finally { if ( wrapper != null ) { - session.getJdbcCoordinator().getResourceRegistry().release( + final JdbcCoordinator jdbcCoordinator = session.getJdbcCoordinator(); + final ResourceRegistry resourceRegistry = jdbcCoordinator.getResourceRegistry(); + resourceRegistry.release( wrapper.getResultSet(), wrapper.getStatement() ); - session.getJdbcCoordinator().getResourceRegistry().release( wrapper.getStatement() ); - session.getJdbcCoordinator().afterStatementExecution(); + resourceRegistry.release( wrapper.getStatement() ); + jdbcCoordinator.afterStatementExecution(); } persistenceContext.afterLoad(); }