@Test
public void testSort() {
Sort sort1 = Sort.by("mno").descending();
Sort sort2 = Sort.by("memoText").ascending();
Sort sortAll = sort1.and(sort2); // and를 이용한 연결
PageRequest pageable = PageRequest.of(0, 10, sort1);
// PageRequest pageable = PageRequest.of(0,10,sortAll); //결합 된 정렬 조건 사용
Page<Memo> result = memoRepository.findAll(pageable);
result.get().forEach(memo -> {
System.out.println(memo);
});
}
728x90
'웹개발 > 스프링부트' 카테고리의 다른 글
| [SpringBoot] Paging test Code (0) | 2021.07.24 |
|---|---|
| RepositoryTest Code (0) | 2021.07.17 |
| application.properties (0) | 2021.07.11 |
| 엔티티 클래스와 JpaRepository (0) | 2021.07.11 |
| Spring Data JPA (0) | 2021.07.11 |