diff --git a/hibernate-core/src/main/java/org/hibernate/boot/internal/NamedProcedureCallDefinitionImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/internal/NamedProcedureCallDefinitionImpl.java index a4eae0ac0b..ea6ff3b03a 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/internal/NamedProcedureCallDefinitionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/internal/NamedProcedureCallDefinitionImpl.java @@ -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 ); } 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 9629dafdcc..57c1743db7 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/FastSessionServices.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/FastSessionServices.java @@ -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; } diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java index ffaf56eedb..fd18d73f90 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java @@ -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(); diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/ResultSetMapping.java b/hibernate-core/src/main/java/org/hibernate/query/results/ResultSetMapping.java index 7551846748..7a6b6e12f7 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/ResultSetMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/ResultSetMapping.java @@ -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 ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/AbstractSqlAstTranslator.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/AbstractSqlAstTranslator.java index ae29952902..3e34ea1142 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/AbstractSqlAstTranslator.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/AbstractSqlAstTranslator.java @@ -867,8 +867,8 @@ public abstract class AbstractSqlAstTranslator implemen private JdbcValuesMappingProducer buildJdbcValuesMappingProducer(SelectStatement selectStatement) { final JdbcValuesMappingProducerProvider producerProvider = getSessionFactory() - .getServiceRegistry() - .getService( JdbcValuesMappingProducerProvider.class ); + .getFastSessionServices() + .getJdbcValuesMappingProducerProvider(); return producerProvider.buildMappingProducer( selectStatement, getSessionFactory() ); }