openrewrite / openrewrite/rewrite-spring

feat: Add UpgradeSpringData_4_0 recipe for Spring Data 2025.1 / Spring Boot 4 migration

Open
#1,063 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

boot-4.0 recipe spring-data
Dominant language
Java
Stars
403
Forks
149
Avg merge
2h 33m
Merged PRs (30d)
10

Description

Is your feature request related to a problem? Please describe.

The current UpgradeSpringBoot_4_0 recipe (spring-boot-40.yml) chains through Spring Boot 3.5, Spring Framework 7.0, Spring Security 7.0 and SpringDoc 3.0 — but it does not include any recipe for Spring Data 2025.1 / Spring Data JPA 4.0.

The docs page at https://docs.openrewrite.org/recipes/java/spring/data only lists recipes up to UpgradeSpringData_3_4. There is no UpgradeSpringData_4_0 recipe, and no spring-data-4.yml file in the repository.

This leaves a significant migration gap for users upgrading to Spring Boot 4 / Spring Data JPA 4.0.6 (released November 2025 as part of the Spring Data 2025.1 release train).

Describe the solution you'd like

A new spring-data-4.yml file with at minimum an UpgradeSpringData_4_0 composite recipe, and the corresponding ChangeType recipes for all class relocations caused by Spring Boot 4's modularization of spring-boot-autoconfigure.

Spring Boot 4 JPA module split — class relocations that need ChangeType coverage

Spring Boot 4.0 introduced three new dedicated modules (spring-boot-jpa, spring-boot-hibernate, spring-boot-persistence), relocating the following classes:

Class Old package (Boot 3.x) New package (Boot 4.x)
EntityManagerFactoryBuilder org.springframework.boot.orm.jpa org.springframework.boot.jpa
JpaProperties org.springframework.boot.autoconfigure.orm.jpa org.springframework.boot.jpa.autoconfigure
JpaBaseConfiguration org.springframework.boot.autoconfigure.orm.jpa org.springframework.boot.jpa.autoconfigure
EntityManagerFactoryBuilderCustomizer org.springframework.boot.autoconfigure.orm.jpa org.springframework.boot.jpa.autoconfigure
HibernateProperties org.springframework.boot.autoconfigure.orm.jpa org.springframework.boot.hibernate.autoconfigure
HibernatePropertiesCustomizer org.springframework.boot.autoconfigure.orm.jpa org.springframework.boot.hibernate.autoconfigure
SpringImplicitNamingStrategy org.springframework.boot.orm.jpa.hibernate org.springframework.boot.hibernate
@EntityScan / EntityScanner org.springframework.boot.autoconfigure.domain org.springframework.boot.persistence.autoconfigure
Spring Data Commons 4.0 — class relocation
Class Old package (SD 3.x) New package (SD 4.x)
PropertyPath org.springframework.data.mapping org.springframework.data.core
Spring Data JPA 4.0 API changes that need recipe coverage

Beyond package moves, the following breaking API changes in Spring Data JPA 4.0 would benefit from automated migration:

  • Specification.where(null) removed → replace with Specification.unrestricted() (the where(null) pattern was very common and is now a compile error since the @Nullable overload was removed)
  • ListenableFuture return type removed from async repository methods → replace with CompletableFuture
Proposed recipe skeleton
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.spring.data.UpgradeSpringData_4_0
displayName: Migrate to Spring Data 4.0
description: >-
  Migrate applications to Spring Data 4.0 (2025.1 release train).
  Handles Spring Boot 4 JPA module class relocations, Spring Data Commons
  PropertyPath move, and Spring Data JPA API breaking changes.
preconditions:
  - org.openrewrite.Singleton
recipeList:
  - org.openrewrite.java.spring.data.UpgradeSpringData_3_4
  # Spring Boot 4 JPA module split — EntityManagerFactoryBuilder
  - org.openrewrite.java.ChangeType:
      oldFullyQualifiedTypeName: org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder
      newFullyQualifiedTypeName: org.springframework.boot.jpa.EntityManagerFactoryBuilder
  # JpaProperties
  - org.openrewrite.java.ChangeType:
      oldFullyQualifiedTypeName: org.springframework.boot.autoconfigure.orm.jpa.JpaProperties
      newFullyQualifiedTypeName: org.springframework.boot.jpa.autoconfigure.JpaProperties
  # JpaBaseConfiguration
  - org.openrewrite.java.ChangeType:
      oldFullyQualifiedTypeName: org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration
      newFullyQualifiedTypeName: org.springframework.boot.jpa.autoconfigure.JpaBaseConfiguration
  # EntityManagerFactoryBuilderCustomizer
  - org.openrewrite.java.ChangeType:
      oldFullyQualifiedTypeName: org.springframework.boot.autoconfigure.orm.jpa.EntityManagerFactoryBuilderCustomizer
      newFullyQualifiedTypeName: org.springframework.boot.jpa.autoconfigure.EntityManagerFactoryBuilderCustomizer
  # HibernateProperties
  - org.openrewrite.java.ChangeType:
      oldFullyQualifiedTypeName: org.springframework.boot.autoconfigure.orm.jpa.HibernateProperties
      newFullyQualifiedTypeName: org.springframework.boot.hibernate.autoconfigure.HibernateProperties
  # HibernatePropertiesCustomizer
  - org.openrewrite.java.ChangeType:
      oldFullyQualifiedTypeName: org.springframework.boot.autoconfigure.orm.jpa.HibernatePropertiesCustomizer
      newFullyQualifiedTypeName: org.springframework.boot.hibernate.autoconfigure.HibernatePropertiesCustomizer
  # SpringImplicitNamingStrategy
  - org.openrewrite.java.ChangeType:
      oldFullyQualifiedTypeName: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
      newFullyQualifiedTypeName: org.springframework.boot.hibernate.SpringImplicitNamingStrategy
  # @EntityScan
  - org.openrewrite.java.ChangeType:
      oldFullyQualifiedTypeName: org.springframework.boot.autoconfigure.domain.EntityScan
      newFullyQualifiedTypeName: org.springframework.boot.persistence.autoconfigure.EntityScan
  # Spring Data Commons — PropertyPath moved to org.springframework.data.core
  - org.openrewrite.java.ChangeType:
      oldFullyQualifiedTypeName: org.springframework.data.mapping.PropertyPath
      newFullyQualifiedTypeName: org.springframework.data.core.PropertyPath
  # Spring Data JPA 4.0 — ListenableFuture removed from async repository methods
  - org.openrewrite.java.spring.data.MigrateListenableFutureToCompletableFuture
  # Upgrade Spring Data dependencies to 4.0.x
  - org.openrewrite.java.dependencies.UpgradeDependencyVersion:
      groupId: org.springframework.data
      artifactId: "*"
      newVersion: 4.0.x
      overrideManagedVersion: false

Note: spring-boot-40-properties.yml already handles the spring.jpa.hibernate.naming.implicit-strategy property value rename — that can be left there or moved here for cohesion.

Describe alternatives you've considered

  • Manual IDE find-replace: Possible but error-prone at scale; not suitable for automated CI-driven migration pipelines.
  • Contributing only to the spring-boot-40.yml chain inline: These changes logically belong in a dedicated spring-data-4.yml file, consistent with the existing spring-data-2.yml / spring-data-3.yml pattern.

Additional context

  • Spring Data 2025.1 GA was released on November 20, 2025, together with Spring Boot 4.0.0 and Spring Framework 7.0.
  • Confirmed gap: UpgradeSpringBoot_4_0 in spring-boot-40.yml does not reference any UpgradeSpringData_4_0 step. This was verified against the current main branch.
  • All class relocations above confirmed against the official Spring Boot 4.0/4.1 Javadoc at https://docs.spring.io/spring-boot/api/java/.
  • Specification.where(null) breaking change confirmed against Spring Data JPA source code diff between branches 3.5.x and 4.0.x on GitHub.
  • The existing spring-data-3.yml pattern (with UpgradeSpringData_3_0UpgradeSpringData_3_4) can be used as a direct structural template.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing src/main/resources/META-INF/rewrite/spring-data-3.yml and spring-boot-40.yml, using the proposed spring-data-4.yml skeleton as the entry point. Implement the UpgradeSpringData_4_0 chain and the listed migration coverage, then verify that Spring Boot 4 upgrades include it and that the documentation lists the new recipe.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
backend, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.