Skip to content

Commit

Permalink
Adapt QuarkusStrategySelectorBuilder to changes in StrategySelectorBu…
Browse files Browse the repository at this point in the history
…ilder

Some of these changes probably pre-date Hibernate ORM 7.0,
we just forgot to implement them.
  • Loading branch information
yrodiere committed Jan 9, 2025
1 parent 636d26d commit bc69dc5
Showing 1 changed file with 29 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.selector.StrategyRegistration;
import org.hibernate.boot.registry.selector.StrategyRegistrationProvider;
import org.hibernate.boot.registry.selector.internal.DefaultDialectSelector;
import org.hibernate.boot.registry.selector.internal.AggregatedDialectSelector;
import org.hibernate.boot.registry.selector.internal.DefaultJtaPlatformSelector;
import org.hibernate.boot.registry.selector.internal.StrategySelectorImpl;
import org.hibernate.boot.registry.selector.spi.DialectSelector;
import org.hibernate.boot.registry.selector.spi.StrategySelector;
import org.hibernate.cache.internal.DefaultCacheKeysFactory;
import org.hibernate.cache.internal.SimpleCacheKeysFactory;
Expand All @@ -22,10 +23,15 @@
import org.hibernate.id.enhanced.LegacyNamingStrategy;
import org.hibernate.id.enhanced.SingleNamingStrategy;
import org.hibernate.id.enhanced.StandardNamingStrategy;
import org.hibernate.query.sqm.mutation.internal.cte.CteInsertStrategy;
import org.hibernate.query.sqm.mutation.internal.cte.CteMutationStrategy;
import org.hibernate.query.sqm.mutation.internal.temptable.GlobalTemporaryTableInsertStrategy;
import org.hibernate.query.sqm.mutation.internal.temptable.GlobalTemporaryTableMutationStrategy;
import org.hibernate.query.sqm.mutation.internal.temptable.LocalTemporaryTableInsertStrategy;
import org.hibernate.query.sqm.mutation.internal.temptable.LocalTemporaryTableMutationStrategy;
import org.hibernate.query.sqm.mutation.internal.temptable.PersistentTableInsertStrategy;
import org.hibernate.query.sqm.mutation.internal.temptable.PersistentTableMutationStrategy;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
import org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorBuilderImpl;
import org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl;
Expand Down Expand Up @@ -59,9 +65,10 @@ public static StrategySelector buildSelector(ClassLoaderService classLoaderServi
// build the baseline...
strategySelector.registerStrategyLazily(
Dialect.class,
new DefaultDialectSelector());
new AggregatedDialectSelector(classLoaderService.loadJavaServices(DialectSelector.class)));
strategySelector.registerStrategyLazily(JtaPlatform.class, new DefaultJtaPlatformSelector());
addTransactionCoordinatorBuilders(strategySelector);
addSqmMultiTableInsertStrategies(strategySelector);
addSqmMultiTableMutationStrategies(strategySelector);
addImplicitNamingStrategies(strategySelector);
addColumnOrderingStrategies(strategySelector);
Expand All @@ -80,9 +87,7 @@ public static StrategySelector buildSelector(ClassLoaderService classLoaderServi
return strategySelector;
}

@SuppressWarnings("unchecked")
private static <T> void applyFromStrategyRegistration(
StrategySelectorImpl strategySelector,
private static <T> void applyFromStrategyRegistration(StrategySelectorImpl strategySelector,
StrategyRegistration<T> strategyRegistration) {
for (String name : strategyRegistration.getSelectorNames()) {
strategySelector.registerStrategyImplementor(
Expand All @@ -103,6 +108,25 @@ private static void addTransactionCoordinatorBuilders(StrategySelectorImpl strat
JtaTransactionCoordinatorBuilderImpl.class);
}

private static void addSqmMultiTableInsertStrategies(StrategySelectorImpl strategySelector) {
strategySelector.registerStrategyImplementor(
SqmMultiTableInsertStrategy.class,
CteInsertStrategy.SHORT_NAME,
CteInsertStrategy.class);
strategySelector.registerStrategyImplementor(
SqmMultiTableInsertStrategy.class,
GlobalTemporaryTableInsertStrategy.SHORT_NAME,
GlobalTemporaryTableInsertStrategy.class);
strategySelector.registerStrategyImplementor(
SqmMultiTableInsertStrategy.class,
LocalTemporaryTableInsertStrategy.SHORT_NAME,
LocalTemporaryTableInsertStrategy.class);
strategySelector.registerStrategyImplementor(
SqmMultiTableInsertStrategy.class,
PersistentTableInsertStrategy.SHORT_NAME,
PersistentTableInsertStrategy.class);
}

private static void addSqmMultiTableMutationStrategies(StrategySelectorImpl strategySelector) {
strategySelector.registerStrategyImplementor(
SqmMultiTableMutationStrategy.class,
Expand Down Expand Up @@ -192,5 +216,4 @@ private static void addXmlFormatMappers(StrategySelectorImpl strategySelector) {
JaxbXmlFormatMapper.SHORT_NAME,
JaxbXmlFormatMapper.class);
}

}

0 comments on commit bc69dc5

Please sign in to comment.