This guide covers the breaking changes in Hibernate Reactive 5.0 and how to migrate your application from 4.x.

Hibernate Reactive 5.0 targets Hibernate ORM 8.0 and Vert.x 5.1.

Hibernate Reactive follows the changes of Hibernate ORM 8.0, which implements Jakarta Persistence 4.0: see also the Hibernate ORM 8.0 migration guide. For example, Hibernate ORM 8.0 no longer processes DTDs or external entities in persistence.xml, orm.xml and hibernate.cfg.xml: see DTD processing and external entities in XML documents.

Dependency changes

Hibernate Reactive Hibernate ORM Vert.x SQL Client

5.0

8.0

5.1

4.5

7.4

5.1

4.x

7.x

5.0

3.4

7.4

4.5

Minimum versions checked at startup

Hibernate Reactive now checks, during bootstrap, that the versions of Hibernate ORM and of the Vert.x SQL client on the classpath aren’t older than the minimum versions it supports. If they are, the creation of the factory fails with:

HR000004: Hibernate Reactive <version> requires <library> <minimum version> or later, but version <version> was found.

Hibernate Reactive 5.0.0.Final and 5.1.0.CR3 require Hibernate ORM 8.0.0.CR2 or later.

This usually means that another platform (BOM) imported before the Hibernate Reactive one manages an older version. Hibernate Reactive publishes a platform, org.hibernate.reactive:hibernate-reactive-platform, that you can use to align the versions.

The check is skipped for snapshots and for versions it can’t parse. You can disable it with the setting hibernate.reactive.skip_version_check=true.

Startup information logged in org.hibernate.reactive.info

The information Hibernate Reactive logs at startup, like its version and the configuration of the pool, now uses the category org.hibernate.reactive.info, the equivalent of org.hibernate.orm.info in Hibernate ORM. If you filter these messages, update the configuration of your logger.

Package renames: .impl to .internal

All org.hibernate.reactive.*.impl sub-packages have been renamed to org.hibernate.reactive.*.internal, aligning with Hibernate ORM conventions.

This is a bulk rename. Any direct import of a class from an .impl package must be updated to .internal.

The most commonly imported classes affected are:

Old import New import

o.h.reactive.pool.impl.SqlClientPoolConfiguration

o.h.reactive.pool.internal.SqlClientPoolConfiguration

o.h.reactive.pool.impl.DefaultSqlClientPool

o.h.reactive.pool.internal.DefaultSqlClientPool

o.h.reactive.pool.impl.DefaultSqlClientPoolConfiguration

o.h.reactive.pool.internal.DefaultSqlClientPoolConfiguration

o.h.reactive.pool.impl.ExternalSqlClientPool

o.h.reactive.pool.internal.ExternalSqlClientPool

o.h.reactive.vertx.impl.ProvidedVertxInstance

o.h.reactive.vertx.internal.ProvidedVertxInstance

o.h.reactive.vertx.impl.DefaultVertxInstance

o.h.reactive.vertx.internal.DefaultVertxInstance

o.h.reactive.mutiny.impl.MutinySessionImpl

o.h.reactive.mutiny.internal.MutinySessionImpl

o.h.reactive.stage.impl.StageSessionImpl

o.h.reactive.stage.internal.StageSessionImpl

o.h.reactive.provider.impl.ReactiveServiceInitiators

o.h.reactive.provider.internal.ReactiveServiceInitiators

A project-wide find-and-replace of org.hibernate.reactive.(\w+)\.impl to org.hibernate.reactive.$1.internal will cover most cases.

FlushMode replaced by QueryFlushMode on queries

The setFlushMode(FlushMode) and setFlushMode(FlushModeType) methods on SelectionQuery and Query (in both the Mutiny and Stage APIs) have been replaced by a single method accepting jakarta.persistence.QueryFlushMode:

// Before (4.x)
session.createQuery("from Book", Book.class)
    .setFlushMode(FlushMode.MANUAL)

// After (5.0)
session.createQuery("from Book", Book.class)
    .setFlushMode(QueryFlushMode.NO_FLUSH)

The setHibernateFlushMode(FlushMode) method has been removed from all reactive query interfaces (ReactiveSelectionQuery, ReactiveMutationQuery, ReactiveQuery, ReactiveNativeQuery).

Session.setFlushMode(FlushMode) is unchanged — this only affects query-level flush mode settings.

createQuery(TypedQueryReference) return type narrowed

Session.createQuery(TypedQueryReference) now returns SelectionQuery<R> instead of Query<R>.

// Before (4.x)
Query<Book> query = session.createQuery(Book_.findAll);

// After (5.0)
SelectionQuery<Book> query = session.createQuery(Book_.findAll);

ReactiveQueryProducer method renames

Several methods on ReactiveQueryProducer (the SPI for creating reactive queries) have been renamed for consistency:

Old name (4.x) New name (5.0)

createNativeReactiveMutationQuery(String)

createReactiveNativeMutationQuery(String)

createNamedReactiveSelectionQuery(String, Class)

createReactiveNamedSelectionQuery(String, Class)

createNamedReactiveMutationQuery(String)

createReactiveNamedMutationQuery(String)

The createNamedReactiveSelectionQuery(String) overload (without a result class) has been removed. Use createReactiveNamedSelectionQuery(String, Class) instead.

The deprecated method createReactiveNativeQuery(String, String, Class) has been removed.

New overloads have been added to ReactiveQueryProducer:

  • createReactiveSelectionQuery(EntityGraph) — create a selection query from an entity graph

  • createReactiveSelectionQuery(CriteriaSelect) — create a selection query from a CriteriaSelect

  • createReactiveSelectionQuery(TypedQueryReference) — create a selection query from a typed reference

  • createReactiveStatement(StatementReference) — create a mutation query from a StatementReference

currentTransaction() detects external transactions

Session.currentTransaction() (on both Mutiny.Session and Stage.Session) now returns a non-null Transaction when a transaction was started externally on the underlying connection (e.g., by a framework-level connection pool), not only when started via withTransaction().

Code that uses currentTransaction() == null to test whether a session-managed transaction is active should be aware that it may now return an ExternalTransaction instance in framework-managed scenarios.

Failed operations roll back the transaction

As in Hibernate ORM, when an operation fails inside withTransaction(), the transaction is marked for rollback only, even if your code recovers from the failure. Hibernate Reactive then rolls it back instead of committing it, and Transaction.isMarkedForRollback() returns true. Before, the transaction was committed.

With hibernate.jpa.compliance.transaction=true, withTransaction() fails with a jakarta.persistence.RollbackException.

As in Jakarta Persistence, NoResultException, NonUniqueResultException, LockTimeoutException and QueryTimeoutException don’t mark the transaction for rollback.

persist() and merge() check references to transient entities

When an entity references a transient entity through a non-nullable association, persist() and merge() now fail with an IllegalStateException, caused by a TransientPropertyValueException, like in Hibernate ORM. Before, Hibernate Reactive reported the error only at flush time, as a TransientObjectException.

When you pass several entities to persist(Object…​) (Stage) or persistAll(Object…​) (Mutiny), the check runs after all of them have been persisted, so the order of the entities doesn’t matter.

PessimisticLockScope.EXTENDED locks the collection tables

With PessimisticLockScope.EXTENDED, Hibernate Reactive now also locks the rows of the element collections and join tables owned by the locked entities, like Hibernate ORM 8.0: in find(), queries, refresh() and lock(), also with follow-on locking. Before, it treated the extended scope like PessimisticLockScope.NORMAL. If you use the extended scope, expect more locked rows, and more waits on them, than before.

With LockMode.PESSIMISTIC_FORCE_INCREMENT and the extended scope, queries now increment the version too.

hibernate.jdbc.time_zone applies to times

Hibernate Reactive now applies hibernate.jdbc.time_zone to the values stored in a time column, like Hibernate ORM: LocalTime, java.sql.Time, and Date mapped with @Temporal(TemporalType.TIME). Before, it stored the time of day in the default time zone of the JVM, and applied the setting only to timestamps.

If you set hibernate.jdbc.time_zone to a time zone that differs from the one of the JVM, the times written by an earlier version are now read shifted by the difference between the two time zones: convert the existing values to the time zone of hibernate.jdbc.time_zone.

Jakarta Persistence settings

Hibernate Reactive now reads the connection and provider settings with the same names, and the same precedence, as Hibernate ORM.

  • javax.persistence.provider is deprecated, and Hibernate Reactive logs a warning when you use it: use jakarta.persistence.provider. If both are present, jakarta.persistence.provider wins.

  • If your application, or a framework, passes jakarta.persistence.provider with a provider other than org.hibernate.reactive.provider.ReactivePersistenceProvider, Hibernate Reactive no longer creates the factory, even if the persistence unit names it as the provider.

  • DefaultSqlClientPool and DefaultSqlClientPoolConfiguration read the URL and the credentials from:

    Hibernate Jakarta Persistence Legacy (deprecated)

    hibernate.connection.url

    jakarta.persistence.jdbc.url

    javax.persistence.jdbc.url

    hibernate.connection.username

    jakarta.persistence.jdbc.user

    javax.persistence.jdbc.user

    hibernate.connection.password

    jakarta.persistence.jdbc.password

    javax.persistence.jdbc.password

    When more than one of them is set, the Hibernate setting wins, then the Jakarta Persistence one. This also applies when a custom pool calls configure() on these classes directly.

  • The error HR000079, reported when the URL is missing, now refers to jakarta.persistence.jdbc.url.

ReactiveAccessCallback.getNextReactiveValue() return type

The return type changed from CompletionStage<IntegralDataTypeHolder> to CompletionStage<Long>, following the removal of IntegralDataTypeHolder in ORM 8.

// Before (4.x)
CompletionStage<IntegralDataTypeHolder> getNextReactiveValue();

// After (5.0)
CompletionStage<Long> getNextReactiveValue();

ReactiveConnection SPI: new currentTransactionId() method

A new default method currentTransactionId() has been added to the ReactiveConnection interface. Custom ReactiveConnection implementations will compile without changes (it defaults to returning null), but should consider overriding it to support external transaction detection.

Named query memento SPI changes

ReactiveNamedSqmQueryMemento and ReactiveNamedNativeQueryMemento had significant API changes following ORM 8.0 refactoring:

  • Several getter methods removed (getResultType(), getFirstResult(), getMaxResults(), getLockOptions(), getCacheable(), getCacheRegion(), getCacheMode(), getReadOnly(), getFetchSize()).

  • getParameterTypes() renamed to getAnticipatedParameterTypes().

  • Integer getTimeout() changed to Timeout getTimeout() (using jakarta.persistence.Timeout).

  • toSelectionQuery() signature changed.

These are SPI classes — only custom query memento implementations are affected.

ORM 8.0 class relocations

Several Hibernate ORM classes have moved packages. If your code imports them directly, update the imports:

Old location New location

org.hibernate.query.sql.spi.NamedNativeQueryMemento

org.hibernate.query.named.spi.NamedNativeQueryMemento

org.hibernate.query.sqm.spi.NamedSqmQueryMemento

org.hibernate.query.named.spi.NamedSqmQueryMemento

org.hibernate.query.named.NamedObjectRepository

org.hibernate.query.named.spi.NamedObjectRepository

org.hibernate.query.named.NamedResultSetMappingMemento

org.hibernate.query.named.spi.NamedResultSetMappingMemento

org.hibernate.query.sqm.tree.select.SqmSelectStatement

org.hibernate.query.sqm.tree.spi.select.SqmSelectStatement

org.hibernate.query.sqm.tree.delete.SqmDeleteStatement

org.hibernate.query.sqm.tree.spi.delete.SqmDeleteStatement

org.hibernate.query.sqm.tree.update.SqmUpdateStatement

org.hibernate.query.sqm.tree.spi.update.SqmUpdateStatement

org.hibernate.query.sqm.tree.insert.SqmInsertStatement

org.hibernate.query.sqm.tree.spi.insert.SqmInsertStatement

org.hibernate.query.sqm.tree.SqmStatement

org.hibernate.query.sqm.tree.spi.SqmStatement

org.hibernate.query.sqm.sql.FromClauseIndex

org.hibernate.query.sqm.sql.spi.FromClauseIndex

org.hibernate.query.results.ResultSetMapping

org.hibernate.query.results.spi.ResultSetMapping

org.hibernate.query.QueryLogging

org.hibernate.query.internal.QueryLogging

org.hibernate.FetchMode (engine)

org.hibernate.engine.FetchStyle

org.hibernate.OrderingMode

org.hibernate.FindMultipleOption.OrderingMode

org.hibernate.RemovalsMode

org.hibernate.FindMultipleOption.RemovalsMode

org.hibernate.SessionCheckMode

org.hibernate.FindMultipleOption.SessionCheckMode

UserType method signatures

Following ORM 8.0, UserType method signatures have changed:

// Before (4.x)
T nullSafeGet(ResultSet rs, int position,
    SharedSessionContractImplementor session, Object owner);
void nullSafeSet(PreparedStatement st, T value, int index,
    SharedSessionContractImplementor session);

// After (5.0)
T nullSafeGet(ResultSet rs, int position, WrapperOptions options);
void nullSafeSet(PreparedStatement st, T value, int index,
    WrapperOptions options);

CallbackRegistryConsumer removed

org.hibernate.jpa.event.spi.CallbackRegistryConsumer has been removed in ORM 8.0. Event listeners that implemented this interface should use EntityPersister.getEntityCallbacks() instead.

Internal class relocations and renames

ReactiveAbstractSelectionQuery has moved from o.h.reactive.query.spi to o.h.reactive.query.internal.

The following internal classes have been renamed:

Old name New name

AggregatedSelectReactiveQueryPlan

ReactiveAggregatedSelectQueryPlan

ConcreteSqmSelectReactiveQueryPlan

ReactiveConcreteSqmSelectQueryPlan

Deleted internal classes

The following internal classes have been removed and replaced:

Deleted class Replacement

ReactiveSqmQueryImpl

ReactiveMutationQueryImpl + ReactiveSelectionQueryImpl

ReactiveSqmSelectionQueryImpl

ReactiveSelectionQueryImpl

Java time types and JDBC direct access

The default of hibernate.type.java_time_use_direct_jdbc is still false, as in Hibernate ORM 7. If you enable it, don’t use it together with the NORMALIZE or NORMALIZE_UTC timezone storage: Hibernate ORM 8.0 doesn’t apply the normalization when the direct JDBC access is enabled.