即使会话已经关闭,我也会遇到开放会话的问题。
//这是我正在调用Service类
的Action类代码TPrfleService tPrfleService=new TPrfleService();
tPrfleService.save(prfle);
//这是我在服务类中的save()
public void save(TPrfle prfle) {
TPrfleExtndDAO tPrfleExtndDAO;
try{
tPrfleExtndDAO = new TPrfleExtndDAO();
tPrfleExtndDAO.save(prfle);
}catch(Exception e){
LoggerImpl.error(e.getMessage());
throw e;
}finally {
tPrfleExtndDAO = null;
}
}
//这是我在DAO课程中的save()
public void save(TPrfle transientInstance) {
LoggerImpl.info("saving TPrfle instance");
try {
getSession(true).saveOrUpdate(transientInstance);
LoggerImpl.info("save successful");
} catch (RuntimeException re) {
LoggerImpl.error("save failed"+ re);
throw re;
}finally{
closeSession(true);
}
}