处理方法: 关闭掉相应的session 问题解决
具体代码:
public PagerModel findAllOrganization(int offset, int pageSize) {
//机构数量 total
String selectCountHQL = "select count(*) from Organization organization";
Session s1 = this.getSessionFactory().openSession();
int total =((Long)s1.createQuery(selectCountHQL).uniqueResult()).intValue();
s1.close();
//所有的机构并分页
String selectHQL = "fromOrganization organization order by organization.id";
Session s2 = this.getSessionFactory().openSession();
List<Organization> list =s2.createQuery(selectHQL).setFirstResult(offset).setMaxResults(pageSize).list();
s2.close();
PagerModel pagerModel = new PagerModel();
pagerModel.setTotal(total);
pagerModel.setList(list);
return pagerModel;
}