diff --git a/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java b/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java index 0e878e8f79..3a92f8d5fd 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java @@ -37,7 +37,6 @@ import org.hibernate.Transaction; import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; import org.hibernate.cache.spi.CacheTransactionSynchronization; -import org.hibernate.dialect.Dialect; import org.hibernate.engine.ResultSetMappingDefinition; import org.hibernate.engine.internal.SessionEventListenerManagerImpl; import org.hibernate.engine.jdbc.LobCreationContext; @@ -562,13 +561,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont @Override public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) { - if ( !sqlTypeDescriptor.canBeRemapped() ) { - return sqlTypeDescriptor; - } - - final Dialect dialect = getJdbcServices().getJdbcEnvironment().getDialect(); - final SqlTypeDescriptor remapped = dialect.remapSqlTypeDescriptor( sqlTypeDescriptor ); - return remapped == null ? sqlTypeDescriptor : remapped; + return fastSessionServices.remapSqlTypeDescriptor( sqlTypeDescriptor ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/internal/FastSessionServices.java b/hibernate-core/src/main/java/org/hibernate/internal/FastSessionServices.java index 2fa489166a..e7c7afe97d 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/FastSessionServices.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/FastSessionServices.java @@ -7,6 +7,7 @@ package org.hibernate.internal; import org.hibernate.cfg.Environment; +import org.hibernate.dialect.Dialect; import org.hibernate.engine.jdbc.spi.JdbcServices; import org.hibernate.event.service.spi.EventListenerRegistry; import org.hibernate.event.spi.AutoFlushEventListener; @@ -26,6 +27,7 @@ import org.hibernate.event.spi.ReplicateEventListener; import org.hibernate.event.spi.ResolveNaturalIdEventListener; import org.hibernate.event.spi.SaveOrUpdateEventListener; import org.hibernate.service.spi.ServiceRegistryImplementor; +import org.hibernate.type.descriptor.sql.SqlTypeDescriptor; import java.util.Objects; @@ -76,6 +78,8 @@ final class FastSessionServices { final boolean disallowOutOfTransactionUpdateOperations; final boolean useStreamForLobBinding; + private final Dialect dialect; + FastSessionServices(SessionFactoryImpl sf) { Objects.requireNonNull( sf ); final ServiceRegistryImplementor sr = sf.getServiceRegistry(); @@ -103,9 +107,10 @@ final class FastSessionServices { this.resolveNaturalIdEventListeners = listeners( eventListenerRegistry, EventType.RESOLVE_NATURAL_ID ); //Other highly useful constants: + this.dialect = jdbcServices.getJdbcEnvironment().getDialect(); this.disallowOutOfTransactionUpdateOperations = !sf.getSessionFactoryOptions().isAllowOutOfTransactionUpdateOperations(); this.useStreamForLobBinding = Environment.useStreamsForBinary() - || jdbcServices.getJdbcEnvironment().getDialect().useInputStreamToInsertBlob(); + || dialect.useInputStreamToInsertBlob(); } Iterable getClearEventListeners() { @@ -184,4 +189,13 @@ final class FastSessionServices { return elr.getEventListenerGroup( type ).listeners(); } + SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) { + if ( !sqlTypeDescriptor.canBeRemapped() ) { + return sqlTypeDescriptor; + } + + final SqlTypeDescriptor remapped = dialect.remapSqlTypeDescriptor( sqlTypeDescriptor ); + return remapped == null ? sqlTypeDescriptor : remapped; + } + }