diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusStrategySelectorBuilder.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusStrategySelectorBuilder.java index 35a4cdfd0b356..6d55f5447556a 100644 --- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusStrategySelectorBuilder.java +++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusStrategySelectorBuilder.java @@ -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; @@ -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; @@ -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); @@ -80,9 +87,7 @@ public static StrategySelector buildSelector(ClassLoaderService classLoaderServi return strategySelector; } - @SuppressWarnings("unchecked") - private static void applyFromStrategyRegistration( - StrategySelectorImpl strategySelector, + private static void applyFromStrategyRegistration(StrategySelectorImpl strategySelector, StrategyRegistration strategyRegistration) { for (String name : strategyRegistration.getSelectorNames()) { strategySelector.registerStrategyImplementor( @@ -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, @@ -192,5 +216,4 @@ private static void addXmlFormatMappers(StrategySelectorImpl strategySelector) { JaxbXmlFormatMapper.SHORT_NAME, JaxbXmlFormatMapper.class); } - }