Closed fabapp2 closed 5 months ago
Hi @fabapp2
for all types inheriting from JpaRepository if method declaration with name public ENTITY getById(ID) exists rename method to get
ByName( )
suggestion:
for all types inheriting from JpaRepository
if method declaration with name public ENTITY getById(ID) exists
and get<ENTITY>ById(<ID>) does not exist
then rename method to get<ENTITY>ById(<ID>)
and then schedule a ChangeName getById -> get<ENTITY>ById recipe via Recipe#doNext
finally schedule a ChangeName getOne -> getBy id recipe via Recipe#doNext
It looks like this was partially implemented in
Those do not seem to take conflicts into account, but I expect those to be rare, and likely to fail safely with a compiler error.
Closing this one as mostly done.
Spring Boot 2.4 to 2.5 upgrade - Spring Data JPA
Spring Boot 2.5 Release Notes
Spring Data JPA introduces a new
getById
method which replacesgetOne
. If you find your application is now throwing aLazyLoadingException
please rename any existinggetById
method togetXyzById
(wherexyz
is an arbitrary string). For more details, please read the updated Spring Data JPA reference documentation.Recipe for repositories with a
getById()
methodCondition
Any class inheriting from
org.springframework.data.jpa.repository.JpaRepository
and declaring agetById(ID)
method is foundMigration
JpaRepository
public ENTITY getById(ID)
existsget<ENTITY>ByName(<ID>)
Scenarios
Custom JpaRepository declares
getById(ID)
**given
expected
Recipe for calls to
getOne()
Condition
Any method call to
org.springframework.data.jpa.repository.JpaRepository getById(ID)
found.Migration
org.springframework.data.jpa.repository.JpaRepository getOne(<TypeOfPK>)
getById(<TypeOfPK>)
Scenarios
Class calls
JpaRepository.getByOne()
given
expected
The recipes must be executed in the given order.!