title: Spring Data: Get Count With Additional Fields
body: <p>I want to return a count of one field plus another field. But I cant transform it into POJO. I can get it only as List of object array. What to I have:</p>
  <pre><code>public interface ChatMessageRepository extends JpaRepository&lt;ChatMessage, Long&gt; {
  
      @Query(value = &quot;select count(c.is_read), c.chat_id from chat_message c where (c.sender_id = :userId or c.receiver_id = :userId) group by c.chat_id&quot;, nativeQuery = true)
      List&lt;Object[]&gt; findAllByUserId(long userId);
  </code></pre>
  <p>But I need something like this:</p>
  <pre><code>@Query(value = &quot;select count(c.is_read), c.chat_id from chat_message c where (c.sender_id = :userId or c.receiver_id = :userId) group by c.chat_id&quot;, nativeQuery = true)
  List&lt;POJO&gt; findAllByUserId(long userId);
  
  @Data
  public static class POJO {
      private long count;
      private long id;
  }
  </code></pre>