title: How to return a custom List with few fields from a custom query with Spring Boot?
body: <p>I'm developing a REST web service with Spring Boot 2 and Java 8. I have a problem in creating a list with few fields compared to when I get a list with all the fields of a table.</p>
  
  <pre class="lang-java prettyprint-override"><code>@Query("SELECT c.idCliente, c.nome, c.cognome, c.username, c.email FROM Cliente c WHERE c.username LIKE %:username%")
  List&lt;Cliente&gt; findClienteByUsername(@Param("username") String username);
  </code></pre>
  
  <p>The result is:</p>
  
  <pre><code>[
     3,
     null,
     null,
     "user",
     "aaa"
  ]
  </code></pre>
  
  <p>But when show all fields get this:</p>
  
  <pre><code>{"idCliente":3,"username":"user","nome":null,"cognome":null,"dataNascita":null,"email":"aaa","password":"ciao","dataCreazione":"2018-11-23T21:33:31.000+0000","instagram":null,"facebook":null,"google":null,"twitter":null,"attivo":"1","ultimaSospensione":null}
  </code></pre>
  
  <p>Why can't I get the field names along with the values?</p>