HHH-16323 Ensure new service ParameterMarkerStrategy can be looked up efficiently
This commit is contained in:
parent
85f98d21f9
commit
faf98a14af
|
@ -66,6 +66,7 @@ import org.hibernate.jpa.internal.util.ConfigurationHelper;
|
|||
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.type.format.FormatMapper;
|
||||
|
||||
import jakarta.persistence.CacheRetrieveMode;
|
||||
|
@ -171,6 +172,7 @@ public final class FastSessionServices {
|
|||
public final EntityCopyObserverFactory entityCopyObserverFactory;
|
||||
public final BatchBuilder batchBuilder;
|
||||
public final Dialect dialect;
|
||||
public final ParameterMarkerStrategy parameterMarkerStrategy;
|
||||
|
||||
//Private fields:
|
||||
private final CacheStoreMode defaultCacheStoreMode;
|
||||
|
@ -232,6 +234,7 @@ public final class FastSessionServices {
|
|||
this.defaultTimeZoneStorageStrategy = sessionFactoryOptions.getDefaultTimeZoneStorageStrategy();
|
||||
this.defaultJdbcBatchSize = sessionFactoryOptions.getJdbcBatchSize();
|
||||
this.requiresMultiTenantConnectionProvider = sessionFactory.getSessionFactoryOptions().isMultiTenancyEnabled();
|
||||
this.parameterMarkerStrategy = serviceRegistry.getService( ParameterMarkerStrategy.class );
|
||||
|
||||
//Some "hot" services:
|
||||
this.connectionProvider = requiresMultiTenantConnectionProvider
|
||||
|
|
|
@ -29,7 +29,7 @@ public class Delete implements RestrictionRenderingContext {
|
|||
private int parameterCount;
|
||||
|
||||
public Delete(SessionFactoryImplementor factory) {
|
||||
this( factory.getServiceRegistry().getService( ParameterMarkerStrategy.class ) );
|
||||
this( factory.getFastSessionServices().parameterMarkerStrategy );
|
||||
}
|
||||
|
||||
public Delete(ParameterMarkerStrategy parameterMarkerStrategy) {
|
||||
|
|
|
@ -38,8 +38,8 @@ public class Insert {
|
|||
|
||||
public Insert(SessionFactoryImplementor sessionFactory) {
|
||||
this(
|
||||
sessionFactory.getJdbcServices().getDialect(),
|
||||
sessionFactory.getServiceRegistry().getService( ParameterMarkerStrategy.class )
|
||||
sessionFactory.getFastSessionServices().dialect,
|
||||
sessionFactory.getFastSessionServices().parameterMarkerStrategy
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.hibernate.LockMode;
|
|||
import org.hibernate.LockOptions;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.internal.FastSessionServices;
|
||||
import org.hibernate.sql.ast.spi.ParameterMarkerStrategy;
|
||||
|
||||
/**
|
||||
|
@ -42,8 +43,20 @@ public class SimpleSelect implements RestrictionRenderingContext {
|
|||
private int parameterCount;
|
||||
|
||||
public SimpleSelect(SessionFactoryImplementor factory) {
|
||||
this.dialect = factory.getJdbcServices().getDialect();
|
||||
this.parameterMarkerStrategy = factory.getServiceRegistry().getService( ParameterMarkerStrategy.class );
|
||||
this.dialect = lookupDialect( factory );
|
||||
this.parameterMarkerStrategy = lookupParameterMarkerStrategy( factory );
|
||||
}
|
||||
|
||||
//A SimpleSelect constructor might be invoked before the FastSessionServices are defined
|
||||
private static Dialect lookupDialect(final SessionFactoryImplementor factory) {
|
||||
final FastSessionServices fastSessionServices = factory.getFastSessionServices();
|
||||
return fastSessionServices != null ? fastSessionServices.dialect : factory.getJdbcServices().getDialect();
|
||||
}
|
||||
|
||||
//A SimpleSelect constructor might be invoked before the FastSessionServices are defined
|
||||
private static ParameterMarkerStrategy lookupParameterMarkerStrategy(final SessionFactoryImplementor factory) {
|
||||
final FastSessionServices fastSessionServices = factory.getFastSessionServices();
|
||||
return fastSessionServices != null ? fastSessionServices.parameterMarkerStrategy : factory.getServiceRegistry().getService( ParameterMarkerStrategy.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,7 +32,7 @@ public class Update implements RestrictionRenderingContext {
|
|||
private int parameterCount;
|
||||
|
||||
public Update(SessionFactoryImplementor factory) {
|
||||
this( factory.getServiceRegistry().getService( ParameterMarkerStrategy.class ) );
|
||||
this( factory.getFastSessionServices().parameterMarkerStrategy );
|
||||
}
|
||||
|
||||
public Update(ParameterMarkerStrategy parameterMarkerStrategy) {
|
||||
|
|
Loading…
Reference in New Issue