Skip to content

Add Spring Data 3.0 upgrade recipe#984

Merged
timtebeek merged 7 commits intomainfrom
spring-data-3.0-upgrade
Apr 1, 2026
Merged

Add Spring Data 3.0 upgrade recipe#984
timtebeek merged 7 commits intomainfrom
spring-data-3.0-upgrade

Conversation

@steve-aom-elliott
Copy link
Copy Markdown
Contributor

Summary

  • Adds MigratePagingAndSortingRepository recipe that detects interfaces extending only PagingAndSortingRepository (which no longer extends CrudRepository in Spring Data 3.0) and adds CrudRepository to their extends clause
  • Adds UpgradeSpringData_3_0 declarative recipe chaining UpgradeSpringData_2_7, the new migration recipe, and a dependency version bump
  • Wires UpgradeSpringData_3_0 into UpgradeSpringFramework_6_0 so both Boot and non-Boot upgrade paths pick it up
  • Fixes UpgradeSpringData_3_4 to chain UpgradeSpringData_3_0 (was previously unchained)

Test plan

  • MigratePagingAndSortingRepositoryTest — adds CrudRepository when only PagingAndSortingRepository is extended
  • No-change when CrudRepository, JpaRepository, or ListCrudRepository already present
  • Handles interfaces with additional custom super-interfaces
  • Skips non-interface class declarations

Spring Data 3.0 changed PagingAndSortingRepository to no longer extend
CrudRepository. Interfaces extending only PagingAndSortingRepository
lose CRUD methods like save(), findById(), and delete().

This adds MigratePagingAndSortingRepository which detects affected
interfaces and adds CrudRepository to their extends clause. It is
wired into a new UpgradeSpringData_3_0 declarative recipe that chains
UpgradeSpringData_2_7 and bumps spring-data dependency versions.

UpgradeSpringData_3_4 now chains UpgradeSpringData_3_0, and
UpgradeSpringFramework_6_0 includes UpgradeSpringData_3_0 so both
Boot and non-Boot upgrade paths pick it up.
@steve-aom-elliott steve-aom-elliott added enhancement New feature or request dependencies Pull requests that update a dependency file recipe Recipe requested spring-data test provided labels Apr 1, 2026
@steve-aom-elliott steve-aom-elliott force-pushed the spring-data-3.0-upgrade branch from deecd05 to 48d00da Compare April 1, 2026 18:32
Check the full type hierarchy when determining if an interface already
has CrudRepository methods, rather than only checking direct supertypes.
This avoids incorrectly adding CrudRepository when it is already
inherited transitively through another interface like JpaRepository.
@steve-aom-elliott steve-aom-elliott marked this pull request as ready for review April 1, 2026 19:15
@steve-aom-elliott steve-aom-elliott moved this from In Progress to Ready to Review in OpenRewrite Apr 1, 2026
…0.yml

Use ListUtils.concat instead of manual ArrayList construction for adding
CrudRepository to implements list. Remove redundant section comment from
spring-data-30.yml.
@timtebeek timtebeek merged commit 7d62388 into main Apr 1, 2026
1 check passed
@timtebeek timtebeek deleted the spring-data-3.0-upgrade branch April 1, 2026 21:10
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file enhancement New feature or request recipe Recipe requested spring-data test provided

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants