zhutianxiang 2009-02-15 11:58
浏览 227
已采纳

Hibernate出个问题,谁帮我解决下

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[]类型的,怎么类型转化出错阿?

  • 写回答

5条回答 默认 最新

  • yighter 2009-02-15 23:21
    关注

    Object[] bill = null;
    bill[i].toString();

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥20 求用stm32f103c6t6在lcd1206上显示Door is open和password:
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法