HHH-16716 Expose ParameterMarkerStrategy on JDBCServices
This commit is contained in:
parent
f6c10f0334
commit
54edf96323
|
@ -8,7 +8,6 @@ package org.hibernate.engine.jdbc.internal;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.jdbc.LobCreationContext;
|
||||
import org.hibernate.engine.jdbc.LobCreator;
|
||||
|
@ -19,10 +18,10 @@ import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
|
|||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
|
||||
import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
|
||||
import org.hibernate.internal.util.config.ConfigurationHelper;
|
||||
import org.hibernate.service.spi.Configurable;
|
||||
import org.hibernate.service.spi.ServiceRegistryAwareService;
|
||||
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
||||
import org.hibernate.sql.ast.spi.ParameterMarkerStrategy;
|
||||
|
||||
/**
|
||||
* Standard implementation of the {@link JdbcServices} contract
|
||||
|
@ -34,6 +33,7 @@ public class JdbcServicesImpl implements JdbcServices, ServiceRegistryAwareServi
|
|||
private JdbcEnvironment jdbcEnvironment;
|
||||
|
||||
private SqlStatementLogger sqlStatementLogger;
|
||||
private ParameterMarkerStrategy parameterMarkerStrategy;
|
||||
|
||||
@Override
|
||||
public void injectServices(ServiceRegistryImplementor serviceRegistry) {
|
||||
|
@ -46,6 +46,7 @@ public class JdbcServicesImpl implements JdbcServices, ServiceRegistryAwareServi
|
|||
assert jdbcEnvironment != null : "JdbcEnvironment was not found";
|
||||
|
||||
this.sqlStatementLogger = serviceRegistry.getService( SqlStatementLogger.class );
|
||||
this.parameterMarkerStrategy = serviceRegistry.getService( ParameterMarkerStrategy.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -71,6 +72,11 @@ public class JdbcServicesImpl implements JdbcServices, ServiceRegistryAwareServi
|
|||
return sqlStatementLogger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParameterMarkerStrategy getParameterMarkerStrategy() {
|
||||
return parameterMarkerStrategy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlExceptionHelper getSqlExceptionHelper() {
|
||||
if ( jdbcEnvironment != null ) {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
package org.hibernate.engine.jdbc.spi;
|
||||
|
||||
import org.hibernate.Incubating;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.jdbc.LobCreationContext;
|
||||
import org.hibernate.engine.jdbc.LobCreator;
|
||||
|
@ -13,6 +14,7 @@ import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
|||
import org.hibernate.engine.jdbc.env.spi.ExtractedDatabaseMetaData;
|
||||
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
|
||||
import org.hibernate.service.Service;
|
||||
import org.hibernate.sql.ast.spi.ParameterMarkerStrategy;
|
||||
import org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl;
|
||||
import org.hibernate.sql.exec.internal.StandardJdbcMutationExecutor;
|
||||
import org.hibernate.sql.exec.spi.JdbcMutationExecutor;
|
||||
|
@ -51,6 +53,13 @@ public interface JdbcServices extends Service {
|
|||
*/
|
||||
SqlStatementLogger getSqlStatementLogger();
|
||||
|
||||
/**
|
||||
* Obtains the service used for marking SQL parameters
|
||||
* @return the registered ParameterMarkerStrategy implementation.
|
||||
*/
|
||||
@Incubating
|
||||
ParameterMarkerStrategy getParameterMarkerStrategy();
|
||||
|
||||
/**
|
||||
* Obtain service for dealing with exceptions.
|
||||
*
|
||||
|
|
|
@ -17,8 +17,8 @@ import org.hibernate.Internal;
|
|||
import org.hibernate.LockMode;
|
||||
import org.hibernate.LockOptions;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.internal.FastSessionServices;
|
||||
import org.hibernate.sql.ast.spi.ParameterMarkerStrategy;
|
||||
|
||||
/**
|
||||
|
@ -42,21 +42,10 @@ public class SimpleSelect implements RestrictionRenderingContext {
|
|||
private final ParameterMarkerStrategy parameterMarkerStrategy;
|
||||
private int parameterCount;
|
||||
|
||||
public SimpleSelect(SessionFactoryImplementor factory) {
|
||||
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 );
|
||||
public SimpleSelect(final SessionFactoryImplementor factory) {
|
||||
final JdbcServices jdbcServices = factory.getJdbcServices();
|
||||
this.dialect = jdbcServices.getDialect();
|
||||
this.parameterMarkerStrategy = jdbcServices.getParameterMarkerStrategy();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -318,9 +318,10 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
|
|||
|
||||
protected AbstractSqlAstTranslator(SessionFactoryImplementor sessionFactory, Statement statement) {
|
||||
this.sessionFactory = sessionFactory;
|
||||
this.dialect = sessionFactory.getJdbcServices().getDialect();
|
||||
final JdbcServices jdbcServices = sessionFactory.getJdbcServices();
|
||||
this.dialect = jdbcServices.getDialect();
|
||||
this.statementStack.push( statement );
|
||||
this.parameterMarkerStrategy = sessionFactory.getServiceRegistry().getService( ParameterMarkerStrategy.class );
|
||||
this.parameterMarkerStrategy = jdbcServices.getParameterMarkerStrategy();
|
||||
}
|
||||
|
||||
private static Clause matchWithClause(Clause clause) {
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.hibernate.service.ServiceRegistry;
|
|||
import org.hibernate.service.spi.ServiceRegistryAwareService;
|
||||
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
||||
import org.hibernate.service.spi.Stoppable;
|
||||
import org.hibernate.sql.ast.spi.ParameterMarkerStrategy;
|
||||
|
||||
import org.hibernate.testing.env.ConnectionProviderBuilder;
|
||||
|
||||
|
@ -44,6 +45,7 @@ public class BasicTestingJdbcServiceImpl implements JdbcServices, ServiceRegistr
|
|||
|
||||
private JdbcConnectionAccess jdbcConnectionAccess;
|
||||
private ServiceRegistry serviceRegistry;
|
||||
private ParameterMarkerStrategy parameterMarkerStrategy;
|
||||
|
||||
public void start() {
|
||||
}
|
||||
|
@ -100,6 +102,11 @@ public class BasicTestingJdbcServiceImpl implements JdbcServices, ServiceRegistr
|
|||
return sqlStatementLogger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParameterMarkerStrategy getParameterMarkerStrategy() {
|
||||
return parameterMarkerStrategy;
|
||||
}
|
||||
|
||||
public SqlExceptionHelper getSqlExceptionHelper() {
|
||||
return jdbcEnvironment.getSqlExceptionHelper();
|
||||
}
|
||||
|
@ -111,5 +118,6 @@ public class BasicTestingJdbcServiceImpl implements JdbcServices, ServiceRegistr
|
|||
@Override
|
||||
public void injectServices(ServiceRegistryImplementor serviceRegistry) {
|
||||
this.serviceRegistry = serviceRegistry;
|
||||
this.parameterMarkerStrategy = serviceRegistry.getService( ParameterMarkerStrategy.class );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue