Skip to content

Upgrade Hibernate ORM to 7.0.0.CR1 #2221

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

Merged
merged 9 commits into from
Apr 25, 2025
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Hibernate Reactive has been tested with:
- CockroachDB v24
- MS SQL Server 2022
- Oracle 23
- [Hibernate ORM][] 7.0.0.Beta4
- [Hibernate ORM][] 7.0.0.CR1
- [Vert.x Reactive PostgreSQL Client](https://vertx.io/docs/vertx-pg-client/java/) 4.5.14
- [Vert.x Reactive MySQL Client](https://vertx.io/docs/vertx-mysql-client/java/) 4.5.14
- [Vert.x Reactive Db2 Client](https://vertx.io/docs/vertx-db2-client/java/) 4.5.14
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ org.gradle.java.installations.auto-download=false
#enableMavenLocalRepo = true

# The default Hibernate ORM version (override using `-PhibernateOrmVersion=the.version.you.want`)
hibernateOrmVersion = 7.0.0.Beta5
hibernateOrmVersion = 7.0.0.CR1

# Override default Hibernate ORM Gradle plugin version
# Using the stable version because I don't know how to configure the build to download the snapshot version from
# a remote repository
#hibernateOrmGradlePluginVersion = 7.0.0.Beta4
#hibernateOrmGradlePluginVersion = 7.0.0.CR1

# If set to true, skip Hibernate ORM version parsing (default is true, if set to null)
# this is required when using intervals or weird versions or the build will fail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@
*/
package org.hibernate.reactive.generator.values.internal;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletionStage;

import org.hibernate.HibernateException;
import org.hibernate.Internal;
import org.hibernate.dialect.Dialect;
Expand Down Expand Up @@ -48,8 +41,15 @@
import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions;
import org.hibernate.type.descriptor.WrapperOptions;

import static org.hibernate.generator.internal.NaturalIdHelper.getNaturalIdPropertyNames;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletionStage;

import static org.hibernate.generator.values.internal.GeneratedValuesHelper.noCustomSql;
import static org.hibernate.internal.NaturalIdHelper.getNaturalIdPropertyNames;
import static org.hibernate.reactive.sql.results.spi.ReactiveListResultsConsumer.UniqueSemantic.NONE;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.util.concurrent.CompletionStage;

import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.event.spi.EventSource;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.loader.ast.spi.MultiIdLoadOptions;
import org.hibernate.metamodel.mapping.EntityIdentifierMapping;
import org.hibernate.metamodel.mapping.EntityMappingType;
Expand Down Expand Up @@ -50,16 +50,16 @@ public EntityMappingType getLoadable() {
}

@Override
public final <K> CompletionStage<List<T>> reactiveLoad(K[] ids, MultiIdLoadOptions loadOptions, EventSource session) {
public final <K> CompletionStage<List<T>> reactiveLoad(K[] ids, MultiIdLoadOptions loadOptions, SharedSessionContractImplementor session) {
Objects.requireNonNull( ids );

return loadOptions.isOrderReturnEnabled()
? performOrderedMultiLoad( ids, loadOptions, session )
: performUnorderedMultiLoad( ids, loadOptions, session );
}

protected abstract <K> CompletionStage<List<T>> performOrderedMultiLoad(K[] ids, MultiIdLoadOptions loadOptions, EventSource session);
protected abstract <K> CompletionStage<List<T>> performOrderedMultiLoad(K[] ids, MultiIdLoadOptions loadOptions, SharedSessionContractImplementor session);

protected abstract <K> CompletionStage<List<T>> performUnorderedMultiLoad(K[] ids, MultiIdLoadOptions loadOptions, EventSource session);
protected abstract <K> CompletionStage<List<T>> performUnorderedMultiLoad(K[] ids, MultiIdLoadOptions loadOptions, SharedSessionContractImplementor session);

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import org.hibernate.engine.spi.EntityKey;
import org.hibernate.engine.spi.PersistenceContext;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.engine.spi.SubselectFetch;
import org.hibernate.event.spi.EventSource;
import org.hibernate.loader.ast.internal.LoaderSelectBuilder;
import org.hibernate.loader.ast.internal.MultiIdEntityLoaderArrayParam;
import org.hibernate.loader.ast.internal.MultiKeyLoadLogging;
Expand Down Expand Up @@ -82,7 +82,7 @@ public BasicEntityIdentifierMapping getIdentifierMapping() {
protected <K> CompletionStage<List<E>> performOrderedMultiLoad(
K[] ids,
MultiIdLoadOptions loadOptions,
EventSource session) {
SharedSessionContractImplementor session) {
if ( MultiKeyLoadLogging.MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
MultiKeyLoadLogging.MULTI_KEY_LOAD_LOGGER.tracef(
"ReactiveMultiIdEntityLoaderArrayParam#performOrderedMultiLoad - %s",
Expand Down Expand Up @@ -227,7 +227,7 @@ protected <K> CompletionStage<List<E>> performOrderedMultiLoad(
protected <K> CompletionStage<List<E>> performUnorderedMultiLoad(
K[] ids,
MultiIdLoadOptions loadOptions,
EventSource session) {
SharedSessionContractImplementor session) {
if ( MultiKeyLoadLogging.MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
MultiKeyLoadLogging.MULTI_KEY_LOAD_LOGGER.tracef(
"ReactiveMultiIdEntityLoaderArrayParam#performUnorderedMultiLoad - %s",
Expand Down Expand Up @@ -305,7 +305,7 @@ protected final <R, K> K[] processResolvableEntities(
MultiIdEntityLoaderArrayParam.ResolutionConsumer<R> resolutionConsumer,
MultiIdLoadOptions loadOptions,
LockOptions lockOptions,
EventSource session) {
SharedSessionContractImplementor session) {
if ( !loadOptions.isSessionCheckingEnabled()
&& !loadOptions.isSecondLevelCacheCheckingEnabled() ) {
// we'll load all of them from the database
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.engine.spi.SubselectFetch;
import org.hibernate.event.spi.EventSource;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.loader.ast.internal.LoaderSelectBuilder;
import org.hibernate.loader.ast.spi.MultiIdLoadOptions;
Expand Down Expand Up @@ -75,7 +74,7 @@ public ReactiveMultiIdEntityLoaderStandard(
protected CompletionStage<List<T>> performOrderedMultiLoad(
Object[] ids,
MultiIdLoadOptions loadOptions,
EventSource session) {
SharedSessionContractImplementor session) {
if ( LOG.isTraceEnabled() ) {
LOG.tracef( "#performOrderedMultiLoad(`%s`, ..)", getEntityDescriptor().getEntityName() );
}
Expand Down Expand Up @@ -289,7 +288,7 @@ private static <T> List<T> singletonList(Object loaded) {
protected CompletionStage<List<T>> performUnorderedMultiLoad(
Object[] ids,
MultiIdLoadOptions loadOptions,
EventSource session) {
SharedSessionContractImplementor session) {
assert !loadOptions.isOrderReturnEnabled();
assert ids != null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ public CompletionStage<T> load(
SharedSessionContractImplementor session) {
final ReactiveSingleIdLoadPlan<T> loadPlan = (ReactiveSingleIdLoadPlan<T>) resolveLoadPlan(
lockOptions,
session.getLoadQueryInfluencers(),
session.getFactory()
session.getLoadQueryInfluencers()
);
return loadPlan.load( key, readOnly, true, session );
}
Expand All @@ -68,7 +67,7 @@ public CompletionStage<T> load(
LockOptions lockOptions,
Boolean readOnly,
SharedSessionContractImplementor session) {
final ReactiveSingleIdLoadPlan<T> loadPlan = (ReactiveSingleIdLoadPlan<T>) resolveLoadPlan( lockOptions, session.getLoadQueryInfluencers(), session.getFactory() );
final ReactiveSingleIdLoadPlan<T> loadPlan = (ReactiveSingleIdLoadPlan<T>) resolveLoadPlan( lockOptions, session.getLoadQueryInfluencers() );
return loadPlan.load( key, entityInstance, readOnly, false, session );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.List;
import java.util.concurrent.CompletionStage;

import org.hibernate.event.spi.EventSource;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.loader.ast.spi.MultiIdEntityLoader;
import org.hibernate.loader.ast.spi.MultiIdLoadOptions;
import org.hibernate.reactive.logging.impl.Log;
Expand All @@ -22,9 +22,9 @@
public interface ReactiveMultiIdEntityLoader<T> extends MultiIdEntityLoader<T> {

@Override
default <K> List<T> load(K[] ids, MultiIdLoadOptions options, EventSource session) {
default <K> List<T> load(K[] ids, MultiIdLoadOptions options, SharedSessionContractImplementor session) {
throw make( Log.class, lookup() ).nonReactiveMethodCall( "reactiveLoad" );
}

<K> CompletionStage<List<T>> reactiveLoad(K[] ids, MultiIdLoadOptions options, EventSource session);
<K> CompletionStage<List<T>> reactiveLoad(K[] ids, MultiIdLoadOptions options, SharedSessionContractImplementor session);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
*/
package org.hibernate.reactive.mutiny;

import java.lang.invoke.MethodHandles;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Function;

import org.hibernate.Cache;
import org.hibernate.CacheMode;
import org.hibernate.Filter;
Expand All @@ -23,7 +18,6 @@
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.jpa.internal.util.FlushModeTypeHelper;
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.query.Order;
import org.hibernate.query.Page;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.hibernate.query.criteria.JpaCriteriaInsert;
Expand All @@ -43,12 +37,17 @@
import jakarta.persistence.FlushModeType;
import jakarta.persistence.LockModeType;
import jakarta.persistence.Parameter;
import jakarta.persistence.TypedQueryReference;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaDelete;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.CriteriaUpdate;
import jakarta.persistence.metamodel.Attribute;
import jakarta.persistence.metamodel.Metamodel;
import java.lang.invoke.MethodHandles;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Function;

import static org.hibernate.engine.internal.ManagedTypeHelper.asPersistentAttributeInterceptable;
import static org.hibernate.engine.internal.ManagedTypeHelper.isPersistentAttributeInterceptable;
Expand Down Expand Up @@ -360,37 +359,6 @@ default SelectionQuery<R> setLockMode(String alias, LockModeType lockModeType) {
return setLockMode( alias, convertToLockMode(lockModeType) );
}

// /**
// * Set the {@link LockOptions} to use for the whole query.
// *
// * @see org.hibernate.query.Query#setLockOptions(LockOptions)
// */
// Query<R> setLockOptions(LockOptions lockOptions);

/**
* If the result type of this query is an entity class, add one or more
* {@linkplain Order rules} for ordering the query results.
*
* @param orderList one or more instances of {@link Order}
*
* @see Order
*
* @see org.hibernate.query.Query#setOrder(List)
*/
SelectionQuery<R> setOrder(List<Order<? super R>> orderList);

/**
* If the result type of this query is an entity class, add a
* {@linkplain Order rule} for ordering the query results.
*
* @param order an instance of {@link Order}
*
* @see Order
*
* @see org.hibernate.query.Query#setOrder(Order)
*/
SelectionQuery<R> setOrder(Order<? super R> order);

/**
* Set the {@link EntityGraph} that will be used as a fetch plan for
* the root entity returned by this query.
Expand Down Expand Up @@ -994,6 +962,22 @@ default Uni<Void> lock(Object entity, LockModeType lockModeType) {
*/
MutationQuery createMutationQuery(JpaCriteriaInsert<?> insert);

/**
* Create a typed {@link org.hibernate.query.Query} instance for the given typed query reference.
*
* @param typedQueryReference the type query reference
*
* @return The {@link org.hibernate.query.Query} instance for execution
*
* @throws IllegalArgumentException if a query has not been
* defined with the name of the typed query reference or if
* the query result is found to not be assignable to
* result class of the typed query reference
*
* @see org.hibernate.query.QueryProducer#createQuery(TypedQueryReference)
*/
<R> Query<R> createQuery(TypedQueryReference<R> typedQueryReference);

/**
* Create an instance of {@link Query} for the given HQL/JPQL query
* string or HQL/JPQL update or delete statement. In the case of an
Expand Down Expand Up @@ -1649,6 +1633,22 @@ default <T> Uni<T> get(Class<T> entityClass, Object id, LockModeType lockModeTyp
@Deprecated
<R> Query<R> createQuery(String queryString);

/**
* Create a typed {@link Query} instance for the given typed query reference.
*
* @param typedQueryReference the type query reference
*
* @return The {@link Query} instance for execution
*
* @throws IllegalArgumentException if a query has not been
* defined with the name of the typed query reference or if
* the query result is found to not be assignable to
* result class of the typed query reference
*
* @see org.hibernate.query.QueryProducer#createQuery(TypedQueryReference)
*/
<R> Query<R> createQuery(TypedQueryReference<R> typedQueryReference);

/**
* Create an instance of {@link SelectionQuery} for the given HQL/JPQL
* query string and query result type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,11 @@
*/
package org.hibernate.reactive.mutiny.impl;

import java.util.List;
import java.util.concurrent.CompletionStage;
import java.util.function.Supplier;

import org.hibernate.CacheMode;
import org.hibernate.FlushMode;
import org.hibernate.LockMode;
import org.hibernate.graph.GraphSemantic;
import org.hibernate.graph.spi.RootGraphImplementor;
import org.hibernate.query.Order;
import org.hibernate.query.Page;
import org.hibernate.reactive.mutiny.Mutiny;
import org.hibernate.reactive.mutiny.Mutiny.Query;
Expand All @@ -27,6 +22,9 @@
import jakarta.persistence.FlushModeType;
import jakarta.persistence.LockModeType;
import jakarta.persistence.Parameter;
import java.util.List;
import java.util.concurrent.CompletionStage;
import java.util.function.Supplier;

public class MutinyQueryImpl<R> implements Query<R> {

Expand Down Expand Up @@ -74,18 +72,6 @@ public Query<R> setLockMode(LockMode lockMode) {
return this;
}

@Override
public Mutiny.SelectionQuery<R> setOrder(List<Order<? super R>> orders) {
delegate.setOrder( orders );
return this;
}

@Override
public Mutiny.SelectionQuery<R> setOrder(Order<? super R> order) {
delegate.setOrder( (List<Order<? super R>>) order );
return this;
}

@Override
public Query<R> setPlan(EntityGraph<R> entityGraph) {
delegate.applyGraph( (RootGraphImplementor<?>) entityGraph, GraphSemantic.FETCH );
Expand Down
Loading
Loading