Reputation: 81
Spring Boot 3. In Spring Boot 3.0 version data jpa, pagingAndSortingRepository seems to inherit Repository and CrudRepository in other versions, is this a change in 3.0?
Then, how do I use the same method as save in 3.0?
Upvotes: 5
Views: 6653
Reputation: 38444
Yes, those are now decoupled since Spring Data Commons 3.0-M2 as we now have CrudRepository
and ListCrudRepository
as well as PagingAndSortingRepository
and ListPagingAndSortingRepository
See the docs for the intended usage: https://docs.spring.io/spring-data/commons/docs/3.0.x/reference/html/#repositories.core-concepts
Additional you can extend
PagingAndSortingRepository
(...) if you need methods that allow to specify aSort
abstraction or in the first case aPageable
abstraction. Note that the various sorting repositories no longer extended their respective CRUD repository as they did in Spring Data Versions pre 3.0. Therefore, you need to extend both interfaces if you want functionality of both.
In other words, extend both (List)CrudRepository AND a (List)PagingAndSortingRepository if you want these methods in Spring Data 3.0+.
Or you can just use the Pageable
and Sort
parameters in your own methods and they will be correctly picked up by the library.
Upvotes: 10