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
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…