query 返回一行多个结果 怎么取

来源:百度知道 编辑:UC知道 时间:2024/06/13 23:15:26
String hql = "select l.id, sum(l.TOTAL_FEE) income from Log l where RETURN_TIME <:endDate and RETURN_TIME >=:startDate group by l.id";

这个是查询语句

返回值有是每一行 一个ID 和一个 值
有多行,应该怎么取出来

String hql = "select l.id, sum(l.TOTAL_FEE) income from Log l where RETURN_TIME <:endDate and RETURN_TIME >=:startDate group by l.id";
Query query = session.createQuery(hql);
ArrayList list = (ArrayList)query.list();

返回的不是List么 循环取出来也可以

返回一个集合,你用循环读出集合中的每一条记录