Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prep for ORM 6.2 #1510

Merged
merged 1 commit into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
import org.hibernate.event.spi.LoadEventListener;
import org.hibernate.loader.ast.internal.CacheEntityLoaderHelper;
import org.hibernate.metamodel.mapping.AttributeMapping;
import org.hibernate.metamodel.mapping.AttributeMappingsList;
import org.hibernate.metamodel.mapping.CompositeIdentifierMapping;
import org.hibernate.metamodel.mapping.EntityIdentifierMapping;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.MappingType;
import org.hibernate.metamodel.mapping.NonAggregatedIdentifierMapping;
import org.hibernate.persister.entity.AttributeMappingsList;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.proxy.LazyInitializer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import org.hibernate.generator.BeforeExecutionGenerator;
import org.hibernate.generator.Generator;
import org.hibernate.metamodel.mapping.AttributeMapping;
import org.hibernate.metamodel.mapping.AttributeMappingsList;
import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.persister.entity.AttributeMappingsList;
import org.hibernate.persister.entity.mutation.EntityTableMapping;
import org.hibernate.persister.entity.mutation.InsertCoordinator;
import org.hibernate.reactive.engine.jdbc.env.internal.ReactiveMutationExecutor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.hibernate.reactive.id.factory.spi.ReactiveIdentifierGeneratorFactoryInitiator;
import org.hibernate.reactive.pool.impl.ReactiveConnectionPoolInitiator;
import org.hibernate.reactive.pool.impl.SqlClientPoolConfigurationInitiator;
import org.hibernate.reactive.provider.service.NativeParametersRendering;
import org.hibernate.reactive.provider.service.NativeParametersHandling;
import org.hibernate.reactive.provider.service.NoJdbcConnectionProviderInitiator;
import org.hibernate.reactive.provider.service.NoJdbcEnvironmentInitiator;
import org.hibernate.reactive.provider.service.NoJdbcMultiTenantConnectionProviderInitiator;
Expand Down Expand Up @@ -154,8 +154,8 @@ private static List<StandardServiceInitiator<?>> buildInitialServiceInitiatorLis
// Custom for Hibernate Reactive: SqmMultiTableMutationStrategyProvider
serviceInitiators.add( ReactiveSqmMultiTableMutationStrategyProviderInitiator.INSTANCE );

// Custom for Hibernate Reactive: NativeParametersRendering
serviceInitiators.add( NativeParametersRendering.INSTANCE );
// Custom for Hibernate Reactive: NativeParametersHandling
serviceInitiators.add( NativeParametersHandling.INSTANCE );

// --- end of services defined by Hibernate ORM

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,50 +16,50 @@
import org.hibernate.reactive.logging.impl.Log;
import org.hibernate.reactive.logging.impl.LoggerFactory;
import org.hibernate.service.spi.ServiceRegistryImplementor;
import org.hibernate.sql.ast.spi.JdbcParameterRenderer;
import org.hibernate.sql.ast.spi.ParameterMarkerStrategy;
import org.hibernate.type.descriptor.jdbc.JdbcType;

/**
* Replaces the JdbcParameterRendererInitiator so to not require
* users to set AvailableSettings.DIALECT_NATIVE_PARAM_MARKERS : this
* gets enforces as the Vert.x SQL clients require it.
*/
public class NativeParametersRendering implements StandardServiceInitiator<JdbcParameterRenderer> {
public class NativeParametersHandling implements StandardServiceInitiator<ParameterMarkerStrategy> {

private static final Log LOG = LoggerFactory.make( Log.class, MethodHandles.lookup() );

/**
* Singleton access
*/
public static final NativeParametersRendering INSTANCE = new NativeParametersRendering();
public static final NativeParametersHandling INSTANCE = new NativeParametersHandling();

@Override
public JdbcParameterRenderer initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
public ParameterMarkerStrategy initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
final Dialect dialect = registry.getService( JdbcServices.class ).getDialect();
final Dialect realDialect = DialectDelegateWrapper.extractRealDialect( dialect );
final JdbcParameterRenderer renderer = recommendRendered( realDialect );
final ParameterMarkerStrategy renderer = recommendRendered( realDialect );
LOG.debug( "Initializing service JdbcParameterRenderer with implementation: " + renderer.getClass() );
return renderer;
}

private JdbcParameterRenderer recommendRendered(Dialect realDialect) {
private ParameterMarkerStrategy recommendRendered(Dialect realDialect) {
if ( realDialect instanceof PostgreSQLDialect ) {
return new PostgreSQLNativeParameterMarkers();
}
//TBD : Implementations for other DBs
else {
return realDialect.getNativeParameterRenderer();
return realDialect.getNativeParameterMarkerStrategy();
}
}

@Override
public Class<JdbcParameterRenderer> getServiceInitiated() {
return JdbcParameterRenderer.class;
public Class<ParameterMarkerStrategy> getServiceInitiated() {
return ParameterMarkerStrategy.class;
}

private static class PostgreSQLNativeParameterMarkers implements JdbcParameterRenderer {
private static class PostgreSQLNativeParameterMarkers implements ParameterMarkerStrategy {
@Override
public String renderJdbcParameter(int position, JdbcType jdbcType) {
public String createMarker(int position, JdbcType jdbcType) {
return "$" + position;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ public CompletionStage<Integer> executeReactiveUpdate(DomainQueryExecutionContex
}
else {
jdbcParameterBinders = new ArrayList<>( parameterList.size() );
jdbcParameterBindings = new JdbcParameterBindingsImpl( parameterList.size() );

jdbcParameterBindings.registerNativeQueryParameters(
jdbcParameterBindings = new JdbcParameterBindingsImpl(
queryParameterBindings,
parameterList,
jdbcParameterBinders,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ public CompletionStage<List<R>> reactivePerformList(DomainQueryExecutionContext
}
else {
jdbcParameterBinders = new ArrayList<>( parameterList.size() );
jdbcParameterBindings = new JdbcParameterBindingsImpl( parameterList.size() );

jdbcParameterBindings.registerNativeQueryParameters(
jdbcParameterBindings = new JdbcParameterBindingsImpl(
queryParameterBindings,
parameterList,
jdbcParameterBinders,
Expand Down