public String[] getBillMess(long shopid,String startdate,String enddate){
String[] bill = null;
Session session = null;
try {
session = this.getSession();
String hql = "select sum(c.consmoney),sum(c.reward) " +
"from Consume c " +
"where c.shopid in (select s.shopid " +
"from Shop s " +
"where s.parentshopid = ?) and " +
"c.paytype = '1' and c.consdate between ? and ? and returncode='0000'";
Query query = session.createQuery(hql);
query.setLong(0, shopid);
query.setString(1, startdate);
query.setString(2, enddate);
List list = query.list();
if(list.size()!=0){
bill = list.get(0);
}
session.flush();
} catch (Exception e) {
e.printStackTrace();
} finally{
session.close();
}
return bill;
}
错误就报在这句上:
bill = list.get(0);
居然说类型转化错误,明明左右两边都是String[]类型阿,Hibernate真奇怪。
如果我要得到String[] bill,那该怎么做???
[b]问题补充:[/b]
List list = query.list();
我这里这句不是用泛型已经将默认的Object[]类型变成String[]了吗?
还有我左边的String[] bill = null;声明过的。所以2边应该都是String[]类型的,怎么类型转化出错阿?