Uploaded image for project: 'Quarkus'
  1. Quarkus
  2. QUARKUS-6261

Upgrade to Hibernate ORM 7, Hibernate Reactive 3 and Hibernate Search 8

XMLWordPrintable

      This upgrades Quarkus to Hibernate ORM 7.

      ~Based on #41359, which must be merged first.~ => Done

      • Closes: #45164
      • Fixes: #43368
      • Fixes: #38948
      • Closes: #42247

      Migration guide entry:

      ```adoc
      == Jakarta Persistence / Hibernate ORM

      === Upgrade to Hibernate ORM 7.0 / Jakarta Persistence 3.2

      The Quarkus extension for Hibernate ORM was upgraded to Hibernate ORM 7.0 / Jakarta Persistence 3.2.

      Hibernate ORM 7.0 is for the most part backwards-compatible with Hibernate ORM 6.6, and comes with [many improvements and new features, as well as a switch from the LGPL license to ASL 2](https://docs.jboss.org/hibernate/orm/7.0/whats-new/whats-new.html).

      However, as with any major version, a few breaking changes are to be expected. Below are the ones most likely to affect existing applications.

      Refer to the https://docs.jboss.org/hibernate/orm/7.0/migration-guide/migration-guide.html[Hibernate ORM 7.0 migration guide] for more information.

      === API changes

      === Behavior changes

      === DDL/schema changes

      Quoting behavior, which suffered from a regression in Hibernate ORM 6.x, was fixed in 7.0 as part of https://hibernate.atlassian.net/browse/HHH-16516[HHH-16516]. Custom database initialization script, in particular on H2, may need to be adapted to avoid use of quotes.

      The following changes will require updating the database schema, and manually updating data:

      The following changes should not require a database schema or data update, as SQL generated by Hibernate should to work even with an older schema:

      === Annotation processor artifact relocation

      Hibernate ORM 7.0 changes the Maven coordinates of its annotation processor responsible for the generation of the static metamodel and Jakarta Data repositories from `org.hibernate.orm:hibernate-jpamodelgen` to `org.hibernate.orm:hibernate-processor`. Make sure to update your `annotationProcessorPath` in Maven, or `annotationProcessor` instruction in Gradle.

      Additionally, the annotation processor `org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor` is now deprecated
      in favor of `org.hibernate.processor.HibernateProcessor`. If your build script was explicitly referring to the processor by name, e.g. with the `annotationProcessors` tag of `maven-compiler-plugin`, make sure to replace the deprecated processor name with the new one.

      === CDI restrictions for Hibernate ORM components

      Some pluggable components, that are potentially retrieved before CDI is initialized, can no longer be CDI beans. This includes in particular:

      • `org.hibernate.type.descriptor.jdbc.JdbcType`
      • `org.hibernate.type.descriptor.java.BasicJavaType`
      • `org.hibernate.type.descriptor.java.JavaType`
      • `org.hibernate.usertype.UserType`
      • `org.hibernate.usertype.UserCollectionType`
      • `org.hibernate.usertype.CompositeUserType`
      • `org.hibernate.type.descriptor.java.MutabilityPlan`
      • `org.hibernate.metamodel.spi.EmbeddableInstantiator`
      • `org.hibernate.generator.Generator` and its subclasses `org.hibernate.id.IdentifierGenerator`, `org.hibernate.generator.AnnotationBasedGenerator`, etc.
      • `org.hibernate.envers.RevisionListener`

      If you need to provide a custom implementation of such components, and need access to CDI within that implementation, consider retrieving other beans when first needed, using `Arc.container().instance(OtherBean.class).get()`.

      == Elasticsearch

      Default connection pool sizes have been bumped https://hibernate.atlassian.net/issues/HSEARCH-5045[to provide a better experience with Hibernate Search], in particular when mass indexing:

      • `quarkus.elasticsearch.max-connections` now defaults to `40` instead of `20`.
      • `quarkus.elasticsearch.max-connections-per-route` now defaults to `20` instead of `10`.

      === Upgrade to Hibernate Search 8.0

      The Quarkus extensions for Hibernate Search were upgraded to Hibernate Search 8.0.

      Hibernate ORM 8.0 is for the most part backwards-compatible with Hibernate Search 7.2, and comes with https://hibernate.org/search/releases/8.0/#whats-new[many improvements and new features], in particular a https://hibernate.org/search/releases/8.0/#static-metamodel[static metamodel]

      However, as with any major version, a few breaking changes are to be expected.
      Below are the ones most likely to affect existing applications.

      Refer to the the https://docs.jboss.org/hibernate/search/8.0/migration/html_single/[Hibernate Search 8.0 migration guide] for more information.

      • Deprecated classes have been removed in favor of their recommended alternatives, in particular `org.hibernate.search.mapper.orm.massindexing.MassIndexingMonitor` => `org.hibernate.search.mapper.pojo.massindexing.MassIndexingMonitor`.
      • `MassIndexingMonitor#addToTotalCount` is now deprecated in favor of the more flexible `MassIndexingMonitor#typeGroupMonitor(..)`
      • `multi()` methods in the projection DSL are deprecated in favor of `.list()`/`.set()`/`sortedSet()`/`collector(...)`.
      • Logging categories have been overhauled. See https://docs.jboss.org/hibernate/search/8.0/reference/en-US/html_single/#logging-categories-aggregated[here for a list of available categories]. In particular, the `org.hibernate.search.elasticsearch.request` logging category, used for logging every request sent to Elasticsearch, has been renamed to `org.hibernate.search.elasticsearch.client.request`.
      • Many Search DSL interfaces now have an extra `SR` type argument to accomodate for the new static metamodel. This mostly affects `*Step` interfaces which should generally not be used in application code.
      • The format of mass indexing logs has changed – for the better, as more information is presented in a more condensed format.

      == Dev Services

      Several Dev Services default images have been updated:

      • Elasticsearch from 8.18 to 9.0
      • OpenSearch from 2.16 to 3.0

      NOTE: You can configure Quarkus explicitly to use a specific image for each Dev Service, e.g. see https://quarkus.io/guides/elasticsearch-dev-services#configuring-the-image[here for Elasticsearch/OpenSearch].
      ```

      Status / next steps:

              rh-ee-yrodiere Yoann Rodière
              blafond Barry LaFond
              Michal Vavrik Michal Vavrik
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: