HHH-14899 Have SessionImpl override the default method getConfiguredJdbcBatchSize

This commit is contained in:
Sanne Grinovero 2021-10-25 17:37:00 +01:00 committed by Sanne Grinovero
parent 5ad60c4b61
commit 959dfea66f
2 changed files with 16 additions and 0 deletions

View File

@ -160,6 +160,7 @@ public final class FastSessionServices {
final boolean discardOnClose; final boolean discardOnClose;
final BaselineSessionEventsListenerBuilder defaultSessionEventListeners; final BaselineSessionEventsListenerBuilder defaultSessionEventListeners;
final LockOptions defaultLockOptions; final LockOptions defaultLockOptions;
final int defaultJdbcBatchSize;
//Private fields: //Private fields:
private final Dialect dialect; private final Dialect dialect;
@ -217,6 +218,7 @@ public final class FastSessionServices {
this.disallowOutOfTransactionUpdateOperations = !sessionFactoryOptions.isAllowOutOfTransactionUpdateOperations(); this.disallowOutOfTransactionUpdateOperations = !sessionFactoryOptions.isAllowOutOfTransactionUpdateOperations();
this.useStreamForLobBinding = Environment.useStreamsForBinary() || dialect.useInputStreamToInsertBlob(); this.useStreamForLobBinding = Environment.useStreamsForBinary() || dialect.useInputStreamToInsertBlob();
this.requiresMultiTenantConnectionProvider = sf.getSettings().getMultiTenancyStrategy().requiresMultiTenantConnectionProvider(); this.requiresMultiTenantConnectionProvider = sf.getSettings().getMultiTenancyStrategy().requiresMultiTenantConnectionProvider();
this.defaultJdbcBatchSize = sessionFactoryOptions.getJdbcBatchSize();
//Some "hot" services: //Some "hot" services:
this.connectionProvider = requiresMultiTenantConnectionProvider ? null : sr.getService( ConnectionProvider.class ); this.connectionProvider = requiresMultiTenantConnectionProvider ? null : sr.getService( ConnectionProvider.class );

View File

@ -300,6 +300,20 @@ public class SessionImpl
return new ActionQueue( this ); return new ActionQueue( this );
} }
/**
* Override the implementation provided on SharedSessionContractImplementor
* which is not very efficient: this method is hot in Hibernate Reactive, and could
* be hot in some ORM contexts as well.
* @return
*/
@Override
public Integer getConfiguredJdbcBatchSize() {
final Integer sessionJdbcBatchSize = getJdbcBatchSize();
return sessionJdbcBatchSize == null ?
fastSessionServices.defaultJdbcBatchSize :
sessionJdbcBatchSize;
}
private LockOptions getLockOptionsForRead() { private LockOptions getLockOptionsForRead() {
return this.lockOptions == null ? fastSessionServices.defaultLockOptions : this.lockOptions; return this.lockOptions == null ? fastSessionServices.defaultLockOptions : this.lockOptions;
} }