title: How to return specific object attributes in spring boot queries with DAO?
body: <p>in my Spring Boot application I have an entity called Person.class, which contains</p>
  <pre><code>long id;
  String email;
  String name;
  String surname;
  String address;
  </code></pre>
  <p>In the DAO class, I have a method:</p>
  <pre><code>List&lt;Person&gt; findAllByEmail(String email);
  </code></pre>
  <p>Which queries the Database and returns a list of Person.</p>
  <p>I would like to return a list of Person with just some attributes, for example:</p>
  <pre><code>long id;
  String email;
  </code></pre>
  <p>Without return the entire object.</p>
  <p>This would be equivalent to execute the query:</p>
  <pre><code>&quot;select id, email from person where email = ?&quot;
  </code></pre>
  <p>But I would like to maintain the function query into the DAO as</p>
  <pre><code>List&lt;Person&gt; findAllByEmail(String email);
  </code></pre>
  <p>Without writing the queries by hand.</p>
  <p>How can I do it ?</p>