Migrate to Hibernate 7.0.x
Recipe ID
io.moderne.hibernate.MigrateToHibernate70Artifact
io.moderne.recipe:rewrite-hibernateThis recipe will apply changes commonly needed when migrating to Hibernate 7.0.x.
Usage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe io.moderne.hibernate.MigrateToHibernate70If the recipe isn’t available locally, install it with:
mod config recipes jar install io.moderne.recipe:rewrite-hibernate:0.26.3Definition
This recipe runs the following recipes in order.
- Migrate to Hibernate 6.6.x
io.moderne.hibernate.MigrateToHibernate66 - Migrate to Hibernate 7.0.x
org.openrewrite.hibernate.MigrateToHibernate70 - Upgrade Gradle or Maven dependency versions
org.openrewrite.java.dependencies.UpgradeDependencyVersion - Change Gradle or Maven dependency
org.openrewrite.java.dependencies.ChangeDependency - Change Gradle or Maven dependency
org.openrewrite.java.dependencies.ChangeDependency - Change Gradle or Maven dependency
org.openrewrite.java.dependencies.ChangeDependency - Remove a Gradle or Maven dependency
org.openrewrite.java.dependencies.RemoveDependency - Add Gradle or Maven dependency
org.openrewrite.java.dependencies.AddDependency - Remove a Gradle or Maven dependency
org.openrewrite.java.dependencies.RemoveDependency - Remove a Gradle or Maven dependency
org.openrewrite.java.dependencies.RemoveDependency - Remove annotation
org.openrewrite.java.RemoveAnnotation - Remove annotation
org.openrewrite.java.RemoveAnnotation - Remove annotation
org.openrewrite.java.RemoveAnnotation - Remove annotation
org.openrewrite.java.RemoveAnnotation - Remove annotation
org.openrewrite.java.RemoveAnnotation - Remove annotation
org.openrewrite.java.RemoveAnnotation - Migrate
@JdbcTypeand legacy@Typeto@JdbcTypeCodeio.moderne.hibernate.update70.MigrateJdbcTypeToJdbcTypeCode - Migrate Session interface method calls
io.moderne.hibernate.update70.MigrateSessionInterface - Migrate Session save/update/delete method calls
io.moderne.hibernate.update70.MigrateSessionToDeferToJPA - Migrate NaturalIdLoadAccess method calls
io.moderne.hibernate.update70.MigrateNaturalIdLoadAccess - Migrate NaturalIdMultiLoadAccess method calls
io.moderne.hibernate.update70.MigrateNaturalIdMultiLoadAccess - Replace hibernate annotations with Jakarta variants
io.moderne.hibernate.update70.ReplaceHibernateWithJakartaAnnotations - Migrate to @TargetEmbeddable
io.moderne.hibernate.update70.MigrateToTargetEmbeddable - Migrate implicit cascade=PERSIST for @Id and @MapsId associations
io.moderne.hibernate.update70.AddCascadePersistToIdMappedAssociations - Replace Session.buildLockRequest with LockOptions
io.moderne.hibernate.update70.ReplaceSessionLockRequest - Migrate LockOptions to direct parameters
io.moderne.hibernate.update70.MigrateLockOptionsToDirectParameters - Null safe Transaction#getTimeout()
io.moderne.hibernate.update70.UnboxingTransactionTimeout - Change type
org.openrewrite.java.ChangeType - Change type
org.openrewrite.java.ChangeType - Change type
org.openrewrite.java.ChangeType - Change type
org.openrewrite.java.ChangeType - Change type
org.openrewrite.java.ChangeType - Change method name
org.openrewrite.java.ChangeMethodName - Remove unnecessary cast to
SessionforSessionFactory.createEntityManager()io.moderne.hibernate.update70.RemoveUnnecessaryCastToSession - Migrate
setFlushMode()tosetQueryFlushMode()io.moderne.hibernate.update70.MigrateSetFlushModeToSetQueryFlushMode - Remove leaking of SharedSessionContractImplementor from
org.hibernate.usertype.UserTypeinvocationsio.moderne.hibernate.update70.UserTypeNullSafeGetSharedSessionContractImplementorRecipe - Remove leaking of SharedSessionContractImplementor from
org.hibernate.usertype.UserTypeimplementationsio.moderne.hibernate.update70.UserTypeSharedSessionContractImplementor - Remove leaking of SessionFactoryImplementor from
org.hibernate.usertype.CompositeUserTypeinvocations and implementationsio.moderne.hibernate.update70.CompositeUserTypeSessionFactoryImplementor - Migrate
MetamodelImplementorto Hibernate 7.0io.moderne.hibernate.update70.MigrateMetamodelImplementor - Migrate
Configurable.configure()to useGeneratorCreationContextio.moderne.hibernate.update70.MigrateConfigurableToGeneratorCreationContext - Migrate Hibernate
Integrator#integratemethodio.moderne.hibernate.update70.MigrateIntegratorMethod - Migrate JPQL
trunc()tocast(... as date)io.moderne.hibernate.update70.MigrateJpqlTruncToDateCast - Migrate @Query to @NativeQuery for unsupported JPQL
io.moderne.hibernate.update70.MigrateQueryToNativeQuery - Find native queries with enum parameters requiring SpEL conversion
io.moderne.hibernate.update70.FindNativeQueryRawEnumParameters - Migrate to Hibernate 7 JFR APIs
io.moderne.hibernate.update70.MigrateToHibernate7JFR
Data tables
Structured output this recipe can produce.
- Source files that had resultsSource files that were modified by the recipe run.
org.openrewrite.table.SourcesFileResults - Source files that had search resultsSearch results that were found during the recipe run.
org.openrewrite.table.SearchResults - Source files that errored on a recipeThe details of all errors produced by a recipe run.
org.openrewrite.table.SourcesFileErrors - Recipe performanceStatistics used in analyzing the performance of recipes.
org.openrewrite.table.RecipeRunStats