From 9e464ccb95bdd15f9706db9c9491a113c069fd16 Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Sun, 23 Apr 2023 22:13:01 +0100 Subject: [PATCH] Upgrade to Hibernate Reactive 2.0.0.CR1 --- bom/application/pom.xml | 2 +- .../SettingsSpyingIdentifierGenerator.java | 1 - ...QuarkusReactiveConnectionPoolInitiator.java | 10 ++-------- .../common/runtime/AbstractJpaOperations.java | 18 ++++++++++++++++++ 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/bom/application/pom.xml b/bom/application/pom.xml index a8a60570e7f4ef..5e7201718a1f7b 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -100,7 +100,7 @@ 6.2.1.Final 1.12.18 6.0.6.Final - 2.0.0.Beta2 + 2.0.0.CR1 8.0.0.Final 6.1.7.Final 6.0.0.Final diff --git a/extensions/hibernate-reactive/deployment/src/test/java/io/quarkus/hibernate/reactive/config/SettingsSpyingIdentifierGenerator.java b/extensions/hibernate-reactive/deployment/src/test/java/io/quarkus/hibernate/reactive/config/SettingsSpyingIdentifierGenerator.java index f1d1f4fe70293a..920269e71b9f58 100644 --- a/extensions/hibernate-reactive/deployment/src/test/java/io/quarkus/hibernate/reactive/config/SettingsSpyingIdentifierGenerator.java +++ b/extensions/hibernate-reactive/deployment/src/test/java/io/quarkus/hibernate/reactive/config/SettingsSpyingIdentifierGenerator.java @@ -23,7 +23,6 @@ public class SettingsSpyingIdentifierGenerator implements IdentifierGenerator { public static final List> collectedSettings = new ArrayList<>(); @Override - @SuppressWarnings({ "unchecked", "rawtypes" }) public void configure(Type type, Properties params, ServiceRegistry serviceRegistry) throws MappingException { collectedSettings.add(new HashMap<>(serviceRegistry.getService(ConfigurationService.class).getSettings())); } diff --git a/extensions/hibernate-reactive/runtime/src/main/java/io/quarkus/hibernate/reactive/runtime/customized/QuarkusReactiveConnectionPoolInitiator.java b/extensions/hibernate-reactive/runtime/src/main/java/io/quarkus/hibernate/reactive/runtime/customized/QuarkusReactiveConnectionPoolInitiator.java index 0aa11409ddabb6..e1611e2bcbeb6c 100644 --- a/extensions/hibernate-reactive/runtime/src/main/java/io/quarkus/hibernate/reactive/runtime/customized/QuarkusReactiveConnectionPoolInitiator.java +++ b/extensions/hibernate-reactive/runtime/src/main/java/io/quarkus/hibernate/reactive/runtime/customized/QuarkusReactiveConnectionPoolInitiator.java @@ -3,13 +3,9 @@ import java.util.Map; import org.hibernate.boot.registry.StandardServiceInitiator; -import org.hibernate.dialect.Dialect; -import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment; import org.hibernate.engine.jdbc.spi.JdbcServices; -import org.hibernate.engine.jdbc.spi.SqlStatementLogger; import org.hibernate.reactive.pool.ReactiveConnectionPool; import org.hibernate.reactive.pool.impl.ExternalSqlClientPool; -import org.hibernate.reactive.pool.impl.Parameters; import org.hibernate.service.spi.ServiceRegistryImplementor; import io.quarkus.hibernate.orm.runtime.migration.MultiTenancyStrategy; @@ -37,10 +33,8 @@ public ReactiveConnectionPool initiateService(Map configurationValues, ServiceRe // nothing to do, but given the separate hierarchies have to handle this here. return null; } - SqlStatementLogger sqlStatementLogger = registry.getService(JdbcServices.class).getSqlStatementLogger(); - final Dialect dialect = registry.getService(JdbcEnvironment.class).getDialect(); - Parameters parameters = Parameters.instance(dialect); - return new ExternalSqlClientPool(pool, sqlStatementLogger, parameters); + final JdbcServices jdbcService = registry.getService(JdbcServices.class); + return new ExternalSqlClientPool(pool, jdbcService.getSqlStatementLogger(), jdbcService.getSqlExceptionHelper()); } } diff --git a/extensions/panache/hibernate-reactive-panache-common/runtime/src/main/java/io/quarkus/hibernate/reactive/panache/common/runtime/AbstractJpaOperations.java b/extensions/panache/hibernate-reactive-panache-common/runtime/src/main/java/io/quarkus/hibernate/reactive/panache/common/runtime/AbstractJpaOperations.java index 8cc1c504042829..e3f5b77ffcf00b 100644 --- a/extensions/panache/hibernate-reactive-panache-common/runtime/src/main/java/io/quarkus/hibernate/reactive/panache/common/runtime/AbstractJpaOperations.java +++ b/extensions/panache/hibernate-reactive-panache-common/runtime/src/main/java/io/quarkus/hibernate/reactive/panache/common/runtime/AbstractJpaOperations.java @@ -360,6 +360,15 @@ public static Mutiny.Query bindParameters(Mutiny.Query query, Object[] par return query; } + public static Mutiny.SelectionQuery bindParameters(Mutiny.SelectionQuery query, Object[] params) { + if (params == null || params.length == 0) + return query; + for (int i = 0; i < params.length; i++) { + query.setParameter(i + 1, params[i]); + } + return query; + } + public static Mutiny.Query bindParameters(Mutiny.Query query, Map params) { if (params == null || params.size() == 0) return query; @@ -369,6 +378,15 @@ public static Mutiny.Query bindParameters(Mutiny.Query query, Map bindParameters(Mutiny.SelectionQuery query, Map params) { + if (params == null || params.size() == 0) + return query; + for (Entry entry : params.entrySet()) { + query.setParameter(entry.getKey(), entry.getValue()); + } + return query; + } + public static Uni executeUpdate(String query, Object... params) { return getSession().chain(session -> { Mutiny.Query jpaQuery = session.createQuery(query);