Skip to Content
Suffering builds character
아카이브19.spring Data특징8.페이징 & 정렬 처리

8.페이징 & 정렬 처리

데이터베이스에서 데이터를 가져오는 단위는 Block 혹은 Page라고 하며,

많은 양의 데이터를 여러 개의 페이지로 나눠 조회하는 방법을 페이징 기법이라고 함
→ 데이터를 페이지 단위로 조회하여 화면 로딩 및 응답 속도를 빠르게 할 수 있음

Spring Data에서는 이러한 페이징 기법을 구현하기 위해 PagingAndSortingRepository 인터페이스를 제공하고 있음

PagingAndSortingRepository.java
@NoRepositoryBean public interface PagingAndSortingRepository<T, ID> extends Repository<T, ID> { /** * Returns all entities sorted by the given options. * @param sort the specification to sort the results by, can be Sort#unsorted(), must not be null. * @return all entities sorted by the given options */ Iterable<T> findAll(Sort sort); Page<T> findAll(Pageable pageable); }
Last updated on