title: Failed to convert from type [java.lang.Object[]] to type
body: <p>I have spring web app (JPA/Hibernate + MySQL).
  I have two DAO classes.</p>
  
  <p><strong>CustomerDAO</strong></p>
  
  <pre><code>@Entity
  @Table(name = "customers")
  public class Customer {
  
    @Id
    @Column(name = "customer_id")
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
  
    @Column(name = "name", length = 50)
    private String name;
  
    @Column(name = "surname", length = 50)
    private String surname;
  
    @OneToMany(mappedBy = "customer")
    private Set&lt;Order&gt; orders = new HashSet&lt;&gt;();
  }
  </code></pre>
  
  <p><strong>OrderDAO</strong></p>
  
  <pre><code>@Entity
  @Table(name = "orders")
  public class Order {
  
    @Id
    @Column(name = "order_id")
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
  
    @Column(name = "date")
    private Date date;
  
    @Digits(integer = 5, fraction = 2)
    @Column(name = "amount")
    private BigDecimal amount;
  
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "customer_id")
    private Customer customer;
  
    @OneToMany(mappedBy = "order")
    private Set&lt;OrderDetail&gt; ordersDetails = new HashSet&lt;&gt;();
  </code></pre>
  
  <p>And i have a class for retrieving data from DB:</p>
  
  <pre><code>@Repository
  public interface OrderDAO extends JpaRepository&lt;Order, Long&gt; {
  
      @Query("select o.customer.surname, sum(o.amount) as s from Order as o group by o.customer")
      List&lt;Customer&gt; findCustomersBySumOfAmount();
  
  }
  </code></pre>
  
  <p>It is giving me result like this:</p>
  
  <pre><code>+---------+---------------+
  | surname | sum of amount | 
  +---------+---------------+
  |Bielecki | 141.49        | 
  |Bielen   | 130.34        |
  ......
  </code></pre>
  
  <p>Now i want 'unbox' data from DB with this method <code>List&lt;Customer&gt; findCustomersBySumOfAmount()</code></p>
  
  <p>I have method for this in my spring controller class:</p>
  
  <pre><code> List&lt;Customer&gt; findCustomersBySumOfAmount = orderService.findCustomersBySumOfAmount();
   model.addAttribute("findCustomersBySumOfAmount", findCustomersBySumOfAmount);
  
   for(Customer c : findCustomersBySumOfAmount) {
       String s = c.getSurname();
       System.out.println(c);
   }
  </code></pre>
  
  <p>And i have error:</p>
  
  <blockquote>
    <p>Failed to convert from type [java.lang.Object[]] to type
    [com.twistezo.models.Customer] for value '{Bielecki, 141.49}'; nested
    exception is
    org.springframework.core.convert.ConverterNotFoundException: No
    converter found capable of converting from type [java.lang.String] to
    type [com.twistezo.models.Customer]</p>
  </blockquote>
  
  <p>I suppose it's because I'm getting <code>List&lt;Object[]&gt;</code>. I know that I can iterate between this <code>List&lt;Object[]&gt;</code> of my data but maybe there is some simpler way to retrieve data directly to <code>&lt;Customer&gt;</code> ? I'm new in this stuff. Since now I used methods like <code>List&lt;Customer&gt; findAll()</code> without @Query annotation and i'm looking for similar "unboxing".</p>
  
  <p>I was trying do something like this (add Customer.class in query) without effect: </p>
  
  <p><code>@Query("select o.customer.surname, sum(o.amount) as s from Order as o group by o.customer", Customer.class)
   List&lt;Customer&gt; findCustomersBySumOfAmount();</code></p>