码迷,mamicode.com
首页 > Web开发 > 详细

Hibernate4运行报错Could not obtain transaction-synchronized Session for current thread

时间:2015-10-30 12:25:25      阅读:298      评论:0      收藏:0      [点我收藏+]

标签:

org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thread
    org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:134)
    org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:1014)
    com.eric.cms.content.dao.UserDaoImpl.addUser(UserDaoImpl.java:21)
    com.eric.cms.content.service.UserServiceImpl.addUser(UserServiceImpl.java:21)
    com.eric.cms.content.controller.LoginController.login(LoginController.java:27)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:175)
    org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:446)
    org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:434)

 原因:hibernate4不支持你用hibernate3的 getcurrentSession,建议你用openSession

Hibernate4运行报错Could not obtain transaction-synchronized Session for current thread

标签:

原文地址:http://www.cnblogs.com/langtianya/p/4922680.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!