HHH-17115 Resolve type pollution problems on lookup of JdbcValuesMappingProducerProvider

This commit is contained in:
Sanne Grinovero 2023-08-22 12:23:33 +02:00 committed by Sanne Grinovero
parent db0427173b
commit a6d1bea5b9
5 changed files with 16 additions and 10 deletions

View File

@ -24,8 +24,6 @@ import org.hibernate.procedure.internal.Util;
import org.hibernate.procedure.spi.NamedCallableQueryMemento;
import org.hibernate.procedure.spi.ParameterStrategy;
import org.hibernate.query.results.ResultSetMapping;
import org.hibernate.query.results.ResultSetMappingImpl;
import org.hibernate.sql.results.jdbc.spi.JdbcValuesMappingProducerProvider;
import jakarta.persistence.NamedStoredProcedureQuery;
import jakarta.persistence.ParameterMode;
@ -129,8 +127,8 @@ public class NamedProcedureCallDefinitionImpl implements NamedProcedureCallDefin
private ResultSetMapping buildResultSetMapping(String registeredName, SessionFactoryImplementor sessionFactory) {
return sessionFactory
.getServiceRegistry()
.getService( JdbcValuesMappingProducerProvider.class )
.getFastSessionServices()
.getJdbcValuesMappingProducerProvider()
.buildResultSetMapping( registeredName, false, sessionFactory );
}

View File

@ -68,6 +68,7 @@ import org.hibernate.jpa.internal.util.LockOptionsHelper;
import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
import org.hibernate.service.spi.ServiceRegistryImplementor;
import org.hibernate.sql.ast.spi.ParameterMarkerStrategy;
import org.hibernate.sql.results.jdbc.spi.JdbcValuesMappingProducerProvider;
import org.hibernate.type.format.FormatMapper;
import jakarta.persistence.CacheRetrieveMode;
@ -182,6 +183,7 @@ public final class FastSessionServices {
private final FormatMapper jsonFormatMapper;
private final FormatMapper xmlFormatMapper;
private final MutationExecutorService mutationExecutorService;
private final JdbcValuesMappingProducerProvider jdbcValuesMappingProducerProvider;
FastSessionServices(SessionFactoryImplementor sessionFactory) {
Objects.requireNonNull( sessionFactory );
@ -250,6 +252,8 @@ public final class FastSessionServices {
this.transactionCoordinatorBuilder = serviceRegistry.getService( TransactionCoordinatorBuilder.class );
this.jdbcServices = serviceRegistry.getService( JdbcServices.class );
this.entityCopyObserverFactory = serviceRegistry.getService( EntityCopyObserverFactory.class );
this.jdbcValuesMappingProducerProvider = serviceRegistry.getService( JdbcValuesMappingProducerProvider.class );
this.isJtaTransactionAccessible = isTransactionAccessible( sessionFactory, transactionCoordinatorBuilder );
@ -369,6 +373,10 @@ public final class FastSessionServices {
return defaultJdbcObservers;
}
public JdbcValuesMappingProducerProvider getJdbcValuesMappingProducerProvider() {
return this.jdbcValuesMappingProducerProvider;
}
public boolean useStreamForLobBinding() {
return useStreamForLobBinding;
}

View File

@ -267,6 +267,7 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im
runtimeMetamodels = runtimeMetamodelsImpl;
final MappingMetamodelImpl mappingMetamodelImpl = new MappingMetamodelImpl( typeConfiguration, serviceRegistry );
runtimeMetamodelsImpl.setMappingMetamodel( mappingMetamodelImpl );
fastSessionServices = new FastSessionServices( this );
initializeMappingModel( mappingMetamodelImpl, bootstrapContext, bootMetamodel, options );
runtimeMetamodelsImpl.setJpaMetamodel( mappingMetamodelImpl.getJpaMetamodel() );
@ -277,7 +278,7 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im
defaultSessionOpenOptions = createDefaultSessionOpenOptionsIfPossible();
temporarySessionOpenOptions = defaultSessionOpenOptions == null ? null : buildTemporarySessionOpenOptions();
defaultStatelessOptions = defaultSessionOpenOptions == null ? null : withStatelessOptions();
fastSessionServices = new FastSessionServices( this );
wrapperOptions = new SessionFactoryBasedWrapperOptions( this );
currentSessionContext = buildCurrentSessionContext();

View File

@ -16,7 +16,6 @@ import org.hibernate.query.NativeQuery;
import org.hibernate.query.named.NamedResultSetMappingMemento;
import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy;
import org.hibernate.sql.results.jdbc.spi.JdbcValuesMappingProducer;
import org.hibernate.sql.results.jdbc.spi.JdbcValuesMappingProducerProvider;
/**
* Acts as the {@link JdbcValuesMappingProducer} for {@link NativeQuery}
@ -96,8 +95,8 @@ public interface ResultSetMapping extends JdbcValuesMappingProducer {
static ResultSetMapping resolveResultSetMapping(String name, boolean isDynamic, SessionFactoryImplementor sessionFactory) {
return sessionFactory
.getServiceRegistry()
.getService( JdbcValuesMappingProducerProvider.class )
.getFastSessionServices()
.getJdbcValuesMappingProducerProvider()
.buildResultSetMapping( name, isDynamic, sessionFactory );
}
}

View File

@ -867,8 +867,8 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
private JdbcValuesMappingProducer buildJdbcValuesMappingProducer(SelectStatement selectStatement) {
final JdbcValuesMappingProducerProvider producerProvider = getSessionFactory()
.getServiceRegistry()
.getService( JdbcValuesMappingProducerProvider.class );
.getFastSessionServices()
.getJdbcValuesMappingProducerProvider();
return producerProvider.buildMappingProducer( selectStatement, getSessionFactory() );
}