Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing CrudRepository#findOne method

I am using Spring 5 in my project. Until today there was available method CrudRepository#findOne.

But after downloading latest snapshot it suddenly disappeared! Is there any reference that the method is not available now?

My dependency list:

apply plugin: 'java' apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management'   repositories {     mavenCentral()     maven { url "https://repo.spring.io/snapshot" }     maven { url "https://repo.spring.io/milestone" } }      dependencies {     compile 'org.springframework.boot:spring-boot-starter-data-jpa'      runtime 'com.h2database:h2:1.4.194' } 

UPDATE:

Seems that this method has been replaced with CrudRepository#findById

like image 480
Andrii Abramov Avatar asked May 21 '17 19:05

Andrii Abramov


People also ask

Which is better CrudRepository or JpaRepository?

Crud Repository doesn't provide methods for implementing pagination and sorting. JpaRepository ties your repositories to the JPA persistence technology so it should be avoided. We should use CrudRepository or PagingAndSortingRepository depending on whether you need sorting and paging or not.

Who implements CrudRepository?

CrudRepository is a Spring data interface and to use it we need to create our interface by extending CrudRepository for a specific type. Spring provides CrudRepository implementation class automatically at runtime. It contains methods such as save , findById , delete , count etc.

What is the use of CrudRepository?

Overview. CrudRepository is a Spring Data interface for generic CRUD operations on a repository of a specific type. It provides several methods out of the box for interacting with a database.


1 Answers

Please see DATACMNS-944 which is associated to this commit which has the following renames

╔═════════════════════╦═══════════════════════╗ ║      Old name       ║       New name        ║ ╠═════════════════════╬═══════════════════════╣ ║ findOne(…)          ║ findById(…)           ║ ╠═════════════════════╬═══════════════════════╣ ║ save(Iterable)      ║ saveAll(Iterable)     ║ ╠═════════════════════╬═══════════════════════╣ ║ findAll(Iterable)   ║ findAllById(…)        ║ ╠═════════════════════╬═══════════════════════╣ ║ delete(ID)          ║ deleteById(ID)        ║ ╠═════════════════════╬═══════════════════════╣ ║ delete(Iterable)    ║ deleteAll(Iterable)   ║ ╠═════════════════════╬═══════════════════════╣ ║ exists()            ║ existsById(…)         ║ ╚═════════════════════╩═══════════════════════╝ 
like image 170
Sean Carroll Avatar answered Oct 24 '22 02:10

Sean Carroll