HHH-13565 Promote field useStreamForLobBinding as cross-Session constant

This commit is contained in:
Sanne Grinovero 2019-08-09 13:00:49 +01:00
parent a39acebde8
commit 8a3c1ee504
2 changed files with 7 additions and 7 deletions

View File

@ -37,7 +37,6 @@ import org.hibernate.Transaction;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.cache.spi.CacheTransactionSynchronization; import org.hibernate.cache.spi.CacheTransactionSynchronization;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.Dialect; import org.hibernate.dialect.Dialect;
import org.hibernate.engine.ResultSetMappingDefinition; import org.hibernate.engine.ResultSetMappingDefinition;
import org.hibernate.engine.internal.SessionEventListenerManagerImpl; import org.hibernate.engine.internal.SessionEventListenerManagerImpl;
@ -143,7 +142,6 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
// transient & non-final for Serialization purposes - ugh // transient & non-final for Serialization purposes - ugh
private transient SessionEventListenerManagerImpl sessionEventsManager = new SessionEventListenerManagerImpl(); private transient SessionEventListenerManagerImpl sessionEventsManager = new SessionEventListenerManagerImpl();
private transient EntityNameResolver entityNameResolver; private transient EntityNameResolver entityNameResolver;
private transient Boolean useStreamForLobBinding;
private Integer jdbcBatchSize; private Integer jdbcBatchSize;
@ -537,11 +535,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
@Override @Override
public boolean useStreamForLobBinding() { public boolean useStreamForLobBinding() {
if ( useStreamForLobBinding == null ) { return fastSessionServices.useStreamForLobBinding;
useStreamForLobBinding = Environment.useStreamsForBinary()
|| getJdbcServices().getJdbcEnvironment().getDialect().useInputStreamToInsertBlob();
}
return useStreamForLobBinding;
} }
@Override @Override

View File

@ -6,6 +6,8 @@
*/ */
package org.hibernate.internal; package org.hibernate.internal;
import org.hibernate.cfg.Environment;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.event.service.spi.EventListenerRegistry; import org.hibernate.event.service.spi.EventListenerRegistry;
import org.hibernate.event.spi.AutoFlushEventListener; import org.hibernate.event.spi.AutoFlushEventListener;
import org.hibernate.event.spi.ClearEventListener; import org.hibernate.event.spi.ClearEventListener;
@ -72,10 +74,12 @@ final class FastSessionServices {
//Intentionally Package private: //Intentionally Package private:
final boolean disallowOutOfTransactionUpdateOperations; final boolean disallowOutOfTransactionUpdateOperations;
final boolean useStreamForLobBinding;
FastSessionServices(SessionFactoryImpl sf) { FastSessionServices(SessionFactoryImpl sf) {
Objects.requireNonNull( sf ); Objects.requireNonNull( sf );
final ServiceRegistryImplementor sr = sf.getServiceRegistry(); final ServiceRegistryImplementor sr = sf.getServiceRegistry();
final JdbcServices jdbcServices = sf.getJdbcServices();
// Pre-compute all iterators on Event listeners: // Pre-compute all iterators on Event listeners:
final EventListenerRegistry eventListenerRegistry = sr.getService( EventListenerRegistry.class ); final EventListenerRegistry eventListenerRegistry = sr.getService( EventListenerRegistry.class );
@ -100,6 +104,8 @@ final class FastSessionServices {
//Other highly useful constants: //Other highly useful constants:
this.disallowOutOfTransactionUpdateOperations = !sf.getSessionFactoryOptions().isAllowOutOfTransactionUpdateOperations(); this.disallowOutOfTransactionUpdateOperations = !sf.getSessionFactoryOptions().isAllowOutOfTransactionUpdateOperations();
this.useStreamForLobBinding = Environment.useStreamsForBinary()
|| jdbcServices.getJdbcEnvironment().getDialect().useInputStreamToInsertBlob();
} }
Iterable<ClearEventListener> getClearEventListeners() { Iterable<ClearEventListener> getClearEventListeners() {