Spring Data returning List<Object[]>
<p>I have this repository:</p>

<pre><code>@Repository
public interface ProductRepository extends JpaRepository&lt;Product, Long&gt;{

@Query("SELECT p.textToSearch as text, count(*) as counter FROM Product p GROUP BY text_to_search ORDER BY counter DESC")
List&lt;TopProductDTO&gt; findTopProducts();
}
</code></pre>

<p>where the TopProductDTO class is:</p>

<pre><code>public class TopProductDTO {

public TopProductDTO() {}

private String text;
private Integer counter;

// Getters and Setters are omited
}
</code></pre>

<p>But when I execute the code</p>

<pre><code>List&lt;TopProductDTO&gt; topProducts = productRepository.findTopProducts();
</code></pre>

<p>It returns a</p>

<pre><code>List&lt;Object[]&gt; insted a List&lt;TopProductDTO&gt;
</code></pre>

<p>As like each column is a index of the Object Array in the list... 
Wasn't it supposed to Spring Data binds the 'text' and 'counter' columns from query with the fields in TopProductDTO?</p>

<p>As result I got a this error in my Thymeleaf Template:</p>

<pre><code>00:37:22.659 [http-nio-8080-exec-5] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "topProductDTO.text" (products/top:46)] with root cause
org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 14): Property or field 'text' cannot be found on object of type 'java.lang.Object[]' - maybe not public?
</code></pre>

<p>I'm using Spring Boot 1.3.3 and Postgres 9.2</p>