Search code examples
javaspring-data

How to convert a page of objects to list in spring data


I have a page of objects like this:

Page<Video> videos = videoRepository.findAllVideos(new PageRequest(1, 50));

How can I convert that to a list of Video objs without iterating over my page?


Solution

  • Page<Video> videos = videoRepository.findAllVideos(new PageRequest(1, 50));
    List<Video> videosList = videos.getContent();
    

    You can use the above code to get the list of videos from page