title: Getting a Page of DTO objects from Spring Data repository
body: <p>I'm trying to use DTOs in a Spring project to decouple business and presentation but I'm having problems while retrieving data from the Spring Data repository. Here I have a sample code:</p>
  
  <pre><code>public Page&lt;UserDto&gt; findAll(int pageIndex) {
      return userRepository.findAll(createPageable(pageIndex)); // Page&lt;User&gt;
  }
  </code></pre>
  
  <p>As you can see, I'm trying to return a page of UserDto but I'm getting a page of User.</p>
  
  <p>How can I do this?</p>