ssh框架关于hibernate中session关闭的问题
package dao.impl;
import java.util.Iterator;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.classic.Session;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.opensymphony.xwork2.ActionContext;
import dao.ManagerDAO;
import entity.Dh0103Staff;
public class ManagerDAOImpl extends HibernateDaoSupport implements ManagerDAO{
public List<Dh0103Staff> findAll(int pagesize,int pagecur,String StaffNumber){
if(StaffNumber==null){
String hql = "from Dh0103Staff";
Query query = getSession().createQuery(hql);
query.setFirstResult((pagecur-1)*pagesize);
query.setMaxResults(pagesize);
List<Dh0103Staff> list = query.list();
getSession().close();
return list;
}
else{
String hql = "from Dh0103Staff d where d.staffNumber like ?";
Query query = getSession().createQuery(hql);
query.setString(0, "%"+StaffNumber+"%");
query.setFirstResult((pagecur-1)*pagesize);
query.setMaxResults(pagesize);
List<Dh0103Staff> list = query.list();
getSession().close();
return list;
}
}
public int count(String staffNumber){
if(staffNumber==null){
String hql = "select count(d.staffId) from Dh0103Staff d where d.staffStae=?";