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

Upgrade to Hibernate Reactive 2.0.0.CR1 #32845

Merged
merged 2 commits into from
Apr 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
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
<hibernate-orm.version>6.2.1.Final</hibernate-orm.version> <!-- When updating, align bytebuddy.version to Hibernate needs as well (just below): -->
<bytebuddy.version>1.12.18</bytebuddy.version> <!-- Version controlled by Hibernate ORM's needs -->
<hibernate-commons-annotations.version>6.0.6.Final</hibernate-commons-annotations.version> <!-- version controlled by Hibernate ORM -->
<hibernate-reactive.version>2.0.0.Beta2</hibernate-reactive.version>
<hibernate-reactive.version>2.0.0.CR1</hibernate-reactive.version>
<hibernate-validator.version>8.0.0.Final</hibernate-validator.version>
<hibernate-search.version>6.1.7.Final</hibernate-search.version>
<narayana.version>6.0.0.Final</narayana.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class SettingsSpyingIdentifierGenerator implements IdentifierGenerator {
public static final List<Map<String, Object>> 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()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Object> params) {
if (params == null || params.size() == 0)
return query;
Expand All @@ -369,6 +378,15 @@ public static Mutiny.Query<?> bindParameters(Mutiny.Query<?> query, Map<String,
return query;
}

public static Mutiny.SelectionQuery<?> bindParameters(Mutiny.SelectionQuery<?> query, Map<String, Object> params) {
if (params == null || params.size() == 0)
return query;
for (Entry<String, Object> entry : params.entrySet()) {
query.setParameter(entry.getKey(), entry.getValue());
}
return query;
}

public static Uni<Integer> executeUpdate(String query, Object... params) {
return getSession().chain(session -> {
Mutiny.Query<?> jpaQuery = session.createQuery(query);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,13 @@ private static ResultHandle lookupUserById(JpaSecurityDefinition jpaSecurityDefi

// session.createQuery("<<HQL>>", UserEntity.class)
ResultHandle query1 = methodCreator.invokeInterfaceMethod(
ofMethod(Mutiny.Session.class, "createQuery", Mutiny.Query.class, String.class, Class.class),
ofMethod(Mutiny.Session.class, "createQuery", Mutiny.SelectionQuery.class, String.class, Class.class),
session, methodCreator.load(hql), userEntityClass);

// .setParameter("name", username)
ResultHandle query2 = methodCreator.invokeInterfaceMethod(
ofMethod(Mutiny.Query.class, "setParameter", Mutiny.Query.class, String.class, Object.class),
ofMethod(Mutiny.SelectionQuery.class, "setParameter", Mutiny.SelectionQuery.class, String.class,
Object.class),
query1, methodCreator.load("name"), username);

// .getSingleResultOrNull()
Expand Down