New object with HQL

Trying to create an object from an HQL query, but just can't figure out what i'm doing wrong.

Query:

String query = "SELECT product.code, SUM(product.price), COUNT(product.code)
from Product AS product
GROUP BY product.code"

(or should I use new MyCustomList(product.code, SUM(... , even though it's not mapped?) Now I want to cast this returned list into a similar object:

class MyCustomList{
  public String code;
  public BigDecimal price;
  public int total;

  // Constructor
  public MyCustomList(String code, String price, int total){ //...

Retrieving the data:

// This throws ClassCastException    
List<MyCustomList> list = MyClass.find(query).fetch();

Using Play framework

28
задан KLE 19 November 2010 в 08:09
поделиться