ssh整合 出现Could not obtain transaction-synchronized Session for current thread

来源:互联网 发布:mac玩qq堂 编辑:程序博客网 时间:2024/06/05 09:57

在ssh整合时出现 错误

         Could not obtain transaction-synchronized Session for current thread

在hibernate3时用的是

getCurrentSession()
但在hibernate4一般是用
openSession()


解决办法:

在 获取session时改为

Session session;try {    session = sessionFactory.getCurrentSession();} catch (HibernateException e) {    session = sessionFactory.openSession();}return session;



如果有错误,请指出谢谢

阅读全文
0 0
原创粉丝点击