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

Ensure Dialects initialzed by Hibernate Reactive extension use the ReactiveDialectWrapper #32086

Merged
merged 1 commit into from
Mar 24, 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 @@ -14,7 +14,7 @@
* the same as Hibernate ORM's default one except it records the dialect
* so that we can reuse it at runtime init.
*/
public final class QuarkusStaticInitDialectFactory extends DialectFactoryImpl
public class QuarkusStaticInitDialectFactory extends DialectFactoryImpl
implements DialectFactory, ServiceRegistryAwareService {

private Dialect dialect;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
import io.quarkus.hibernate.orm.runtime.service.QuarkusImportSqlCommandExtractorInitiator;
import io.quarkus.hibernate.orm.runtime.service.QuarkusMutableIdentifierGeneratorFactoryInitiator;
import io.quarkus.hibernate.orm.runtime.service.QuarkusRegionFactoryInitiator;
import io.quarkus.hibernate.orm.runtime.service.QuarkusStaticInitDialectFactoryInitiator;
import io.quarkus.hibernate.orm.runtime.service.StandardHibernateORMInitiatorListProvider;
import io.quarkus.hibernate.reactive.runtime.customized.QuarkusNoJdbcConnectionProviderInitiator;
import io.quarkus.hibernate.reactive.runtime.customized.QuarkusReactiveDialectFactoryInitiator;

/**
* Defines the initial list of StandardServiceInitiator instances used to initialize the
Expand Down Expand Up @@ -86,8 +86,8 @@ public List<StandardServiceInitiator<?>> initialInitiatorList() {
serviceInitiators.add(MultiTenantConnectionProviderInitiator.INSTANCE);
serviceInitiators.add(DialectResolverInitiator.INSTANCE);

// Custom Quarkus implementation !
serviceInitiators.add(QuarkusStaticInitDialectFactoryInitiator.INSTANCE);
// Custom Quarkus V Reactive implementation !
serviceInitiators.add(QuarkusReactiveDialectFactoryInitiator.INSTANCE);

// Default implementation
serviceInitiators.add(BatchBuilderInitiator.INSTANCE);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.quarkus.hibernate.reactive.runtime.customized;

import java.util.Map;

import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.engine.jdbc.dialect.spi.DialectFactory;
import org.hibernate.service.spi.ServiceRegistryImplementor;

public final class QuarkusReactiveDialectFactoryInitiator implements StandardServiceInitiator<DialectFactory> {

public static final QuarkusReactiveDialectFactoryInitiator INSTANCE = new QuarkusReactiveDialectFactoryInitiator();

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

@Override
public DialectFactory initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
return new ReactiveQuarkusStaticInitDialectFactory();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.quarkus.hibernate.reactive.runtime.customized;

import java.util.Map;

import org.hibernate.HibernateException;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.dialect.spi.DialectFactory;
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfoSource;
import org.hibernate.reactive.dialect.ReactiveDialectWrapper;
import org.hibernate.service.spi.ServiceRegistryAwareService;

import io.quarkus.hibernate.orm.runtime.service.QuarkusStaticInitDialectFactory;

public class ReactiveQuarkusStaticInitDialectFactory extends QuarkusStaticInitDialectFactory
implements DialectFactory, ServiceRegistryAwareService {

private Dialect wrapDialect;

@Override
public Dialect buildDialect(Map<String, Object> map, DialectResolutionInfoSource dialectResolutionInfoSource)
throws HibernateException {
this.wrapDialect = new ReactiveDialectWrapper(super.buildDialect(map, dialectResolutionInfoSource));
return this.wrapDialect;
}

@Override
public Dialect getDialect() {
return this.wrapDialect;
}
}