String hql = "select bg.id as id,bg.groupId as groupId, b.id as businessId,"+" g.name as groupName,b.name as businessName"
+" from Business b, Businessgroup bg, Groups g "
+" where bg.groupId=g.id and bg.businessId=b.id order by bg.groupId asc";
Session session = this.getSession();
Query query = session.createQuery(hql);
query.setFirstResult(start);
query.setMaxResults(limit);
query.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);//这样会把所有查询的列放到一个元素为Map的list中。
return query.list();
然后遍历list,从map中以列明为键值取出相应的value,再set到po中
for(int i=0; i<list.size(); i++){
map = (Map) list.get(i);
}
此方法来自互联网。
+" from Business b, Businessgroup bg, Groups g "
+" where bg.groupId=g.id and bg.businessId=b.id order by bg.groupId asc";
Session session = this.getSession();
Query query = session.createQuery(hql);
query.setFirstResult(start);
query.setMaxResults(limit);
query.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);//这样会把所有查询的列放到一个元素为Map的list中。
return query.list();
然后遍历list,从map中以列明为键值取出相应的value,再set到po中
for(int i=0; i<list.size(); i++){
map = (Map) list.get(i);
}
此方法来自互联网。
本文介绍了一种使用HQL进行分页查询的方法,并详细解释了如何通过设置查询语句来获取特定范围内的数据记录。此外,还展示了如何利用Hibernate框架进行查询操作,并通过示例代码说明了如何将查询结果转化为实体对象。
1万+

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



