如何将所有对象传递给 Pageable

How to pass all objects to Pageable

我有一个方法,我只从数据库传递 6 个对象:

StudentDTO students = StudentDTO.builder()
            .fieldName("studentCity")
            .postDTOS(postRepository.findStudentByCity(
                    PageRequest.of(pageable.getPageNumber(), 6))
                    .map(postMapper::toPostDTO).toSet()).build();

如何重写它以传递所有值,而不是 6?

使用Pageable.unpaged();获取所有记录:

StudentDTO students = StudentDTO.builder()
            .fieldName("studentCity")
            .postDTOS(postRepository.findStudentByCity(
                    Pageable.unpaged())
                    .map(postMapper::toPostDTO).toSet()).build()