HHH-13478 Avoiding some duplicate getter executions in DynamicBatchingEntityLoaderBuilder

This commit is contained in:
Sanne Grinovero 2019-06-28 14:33:53 +01:00
parent 727dac4772
commit 8e3660b736
1 changed files with 8 additions and 4 deletions

View File

@ -19,6 +19,8 @@ import org.hibernate.LockMode;
import org.hibernate.LockOptions;
import org.hibernate.dialect.pagination.LimitHelper;
import org.hibernate.engine.internal.BatchFetchQueueHelper;
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.spi.EntityEntry;
import org.hibernate.engine.spi.EntityKey;
import org.hibernate.engine.spi.LoadQueryInfluencers;
@ -443,12 +445,13 @@ public class DynamicBatchingEntityLoaderBuilder extends BatchingEntityLoaderBuil
SharedSessionContractImplementor session,
QueryParameters queryParameters,
Serializable[] ids) {
final JdbcServices jdbcServices = session.getJdbcServices();
final String sql = StringHelper.expandBatchIdPlaceholder(
sqlTemplate,
ids,
alias,
persister.getKeyColumnNames(),
session.getJdbcServices().getJdbcEnvironment().getDialect()
jdbcServices.getJdbcEnvironment().getDialect()
);
try {
@ -483,7 +486,7 @@ public class DynamicBatchingEntityLoaderBuilder extends BatchingEntityLoaderBuil
}
}
catch ( SQLException sqle ) {
throw session.getJdbcServices().getSqlExceptionHelper().convert(
throw jdbcServices.getSqlExceptionHelper().convert(
sqle,
"could not load an entity batch: " + MessageHelper.infoString(
getEntityPersisters()[0],
@ -509,8 +512,9 @@ public class DynamicBatchingEntityLoaderBuilder extends BatchingEntityLoaderBuil
return processResultSet( rs, queryParameters, session, false, null, maxRows, afterLoadActions );
}
finally {
session.getJdbcCoordinator().getLogicalConnection().getResourceRegistry().release( st );
session.getJdbcCoordinator().afterStatementExecution();
final JdbcCoordinator jdbcCoordinator = session.getJdbcCoordinator();
jdbcCoordinator.getLogicalConnection().getResourceRegistry().release( st );
jdbcCoordinator.afterStatementExecution();
}
}
}