SQLite实现分页排序

版本号

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 page = scriptsRepository.findAll(pageable);

自定义查询

@Repository
public interface ScriptRelatedTablesRepository extends JpaRepository {
    @Query("select u from User u where u.id <= ?1")
  Page findWithPage(Long id, Pageable pageable);
}

你可能感兴趣的:(SQLite,JAVA,sqlite,java,数据库)