title: Spring Data JPA and Querydsl to fetch subset of columns using bean/constructor projection
body: <p>I have an entity class as below:</p>
  
  
  
  <pre class="lang-java prettyprint-override"><code>@Entity
  public class UserDemo implements Serializable {
  
      @Id
      private Long id;
  
      private String username;
  
      private String createdBy;
      @Version
      private int version;
  
      /***
       *
       * Getters and setters
       */
  }
  </code></pre>
  
  <p><br>
  Using Spring Data JPA and Querydsl how do I fetch a page of <em>UserDemo</em> with only <code>id</code> and <code>username</code> properties populated? I need to use paging as well as searching. In short I would like to achieve the same result as</p>
  
  <pre class="lang-java prettyprint-override"><code>Page&lt;UserDemo&gt; findAll(Predicate predicate, Pageable pageable);
  </code></pre>
  
  <p>but with limited field of <em>UserDemo</em> populated.</p>