SessionFactoryUtils打开的Session需要关闭吗?我在log中发现[org.hibernate.jdbc.ConnectionManager]-[WARN] unclosed connection, forgot to call close() on your session?
我的代码是这样的 - public class BaseDao extends HibernateDaoSupport{
- public Session openSession(); {
- //modify for non transactional
- return SessionFactoryUtils.getSession(getSessionFactory();, true);;
- }
- ....
- }
- public class WebUserDaoImpl extends BaseDao implements IWebUserDao{
- Session session = this.openSession();;
- Transaction tx = session.beginTransaction();;
- String hqlUpdate = "update WebUser set nickname = ? where userId = ?";
- session.createQuery(hqlUpdate);.setString(0,nickname);.setString(1,userID);.executeUpdate();;
- tx.commit();;
- //session.close();;
- }
复制代码 |
|