版本号
MacOS Apple M1 | Jdk17 | Maven 3.8.5 | SpringBoot 2.6.9 | 内嵌式 Sqlite 3.42.0.0
Pageable 使用方式
findAll()
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
// 根据 score 字段升序分页
Pageable pageable = PageRequest.of(current, pageSize, Sort.by(Sort.Direction.ASC, "score"));
// Student 为自定义 entity
Page<Student> page = scriptsRepository.findAll(pageable);
自定义查询
@Repository
public interface ScriptRelatedTablesRepository extends JpaRepository<User, Long> {
@Query("select u from User u where u.id <= ?1")
Page<User> findWithPage(Long id, Pageable pageable);
}
标签:sqlite,分页,domain,springframework,org,import,排序,data,Pageable
From: https://www.cnblogs.com/pandacode/p/17644155.html