org.hibernate.HibernateException: No CurrentSessionContext configured
解决如下:
在集成Hibernate的环境下(例如Jboss),在hibernate.cfg.xml中session-factory段加入:
<property name="current_session_context_class">jta</property>
在不集成Hibernate的环境下(例如使用JDBC的独立应用程序),在hibernate.cfg.xml中session-factory段加入:
<property name="current_session_context_class">thread</property>
本文介绍了解决Hibernate在不同环境下出现NoCurrentSessionContext异常的方法。针对集成Hibernate的环境如Jboss,需要配置jta作为当前会话上下文;对于非集成环境如使用JDBC的应用,则需要设置thread为当前会话上下文。
2898

被折叠的 条评论
为什么被折叠?



