HHH-13565 Dialect is another constant

This commit is contained in:
Sanne Grinovero 2019-08-09 13:05:17 +01:00
parent 8a3c1ee504
commit 72ce71ef10
2 changed files with 16 additions and 9 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.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

View File

@ -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<ClearEventListener> 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;
}
}