I have a method where I pass only 6 objects from database :
StudentDTO students = StudentDTO.builder()
.fieldName("studentCity")
.postDTOS(postRepository.findStudentByCity(
PageRequest.of(pageable.getPageNumber(), 6))
.map(postMapper::toPostDTO).toSet()).build();
How can I rewrite it in order to pass all values, not 6?
CodePudding user response:
Use Pageable.unpaged();
to fetch all the records:
StudentDTO students = StudentDTO.builder()
.fieldName("studentCity")
.postDTOS(postRepository.findStudentByCity(
Pageable.unpaged())
.map(postMapper::toPostDTO).toSet()).build()