1、 Hibernate group by 和having
hql语句如下,
Object[] pramas ={ timeBegin ,timeEnd,mincount ,maxcount};
return syslogDao.findForPage("select username ,count(id) , max(createtime) from Syslog " +
" where createtime > ? and createtime < ? " +
"group by username having count(id) > ? and count(id) < ?", pramas ,pageSize ,page);
前台使用struts2标签取值,需要注意定义id="list"
2 、hibernate的select 读取结果集的两种显示方法
List newList = new ArrayList();
for(int i=0;i<list.size();i++){
Map map = new HashMap();
前台调用:<s:iteratorvalue="#request.list"id="list">姓名:<s:propertyvalue="#list.username"/>数量:<s:propertyvalue="#list.count"/></s:iterator>
本文介绍了如何在Hibernate中利用HQL结合group by和having子句进行统计功能的实现。示例展示了查询特定时间范围内,按用户名分组且记录数在指定范围内的日志记录。同时,提到了在Struts2标签中读取和展示这些统计结果的注意事项。
1161

被折叠的 条评论
为什么被折叠?



