title: How to make a get all records using pageable in springboot
body: <p>I am trying to get all records from a h2 database using pageable. I can pull the results using normal findAll(), but when I try using pageable, I am not able to</p>
  <p>This is my controller</p>
  <pre><code>@GetMapping
  Page&lt;PostInfo&gt; getPosts(Pageable pageable) {
      return postService.getPosts(pageable);
  }
  </code></pre>
  <p>this are my models
  My Post model</p>
  <pre><code>@Data
  @ToString
  @Entity
  @Table(name = &quot;POST&quot;)
  public class Post {
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
      private String title;
      private String content;
  }
  </code></pre>
  <p>My Postdetails class which extends postinfo</p>
  <pre><code>@Data
  @ToString
  public class PostDetails extends PostInfo {
      private String content;
  }
  </code></pre>
  <p>My Postinfo class</p>
  <pre><code>@Data
  @ToString
  @Entity
  public class PostInfo {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
      private String title;
  }
  </code></pre>
  <p>My PostService service class</p>
  <pre><code>public interface PostService {
  
      PostDetails createPost(@Valid CreatePostRequest createPostRequest);
  
      Page&lt;PostInfo&gt;getPosts(final Pageable pageable);
  
      PostDetails getPostDetails(Long id);
  
      void deletePost(Long id);
  }
  </code></pre>
  <p>My Implementation class</p>
  <pre><code> @Override
      public Page&lt;PostInfo&gt; getPosts(Pageable pageable) {
         return postRepository.findAll(pageable);
  
      }
  </code></pre>
  <p>I end up getting not getting pageable data. How can I use pageable to findAll() records stored. I have researched with no luck. Any help is appreciated. Thanks in advance.</p>