Friday, May 29, 2020

Can't use findOne() in my code with JpaRepository

Can't use findOne() in my code with JpaRepository:

Use findById().get() instead of findOne()

yourRespository.findById(id).get();// it will return an Optional instead of null

yourRespository.findById(id).orElse(null); // this will return null if you have proper null checks
There have been some changes with the recent versions of spring data JPA and they have removed the findOne() the method which used work earlier.

No comments:

Post a Comment