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>