用Hibernate开发遇到"No CurrentSessionContext configured"错误
2008-12-04 18:49
489 查看
在使用SessionFactory的getCurrentSession方法时遇到如下错误,经过检查,原因如下:
是因为在hibernate.cfg.xml文件中忘记进行了如下设置:hibernate.current_session_context_class
如果是在web容器中运行hibernate,则在hibernate.cfg.xml中加入这句话:
<property name="hibernate.current_session_context_class">jta</property>
如果是在一个单独的需要进行JDBC连接的java application中运行hibernate,则这样设置:
<property name="hibernate.current_session_context_class">thread</property>
是因为在hibernate.cfg.xml文件中忘记进行了如下设置:hibernate.current_session_context_class
如果是在web容器中运行hibernate,则在hibernate.cfg.xml中加入这句话:
<property name="hibernate.current_session_context_class">jta</property>
如果是在一个单独的需要进行JDBC连接的java application中运行hibernate,则这样设置:
<property name="hibernate.current_session_context_class">thread</property>
相关文章推荐
- 用Hibernate开发遇到"No CurrentSessionContext configured"错误
- 用Hibernate开发遇到"No CurrentSessionContext configured"错误
- "No CurrentSessionContext configured"错误(hibernate)
- No CurrentSessionContext configured"错误(hibernate
- Exception in thread "main" org.hibernate.HibernateException: No CurrentSessionContext configured!
- 错误:org.hibernate.HibernateException: No CurrentSessionContext configured!
- "No CurrentSessionContext configured"错误
- "No CurrentSessionContext configured"错误
- 错误:org.hibernate.HibernateException: No CurrentSessionContext configured!
- 依据错误原理解决Hibernate执行出现No CurrentSessionContext configured!错误
- Exception in thread "main" org.hibernate.HibernateException: No CurrentSessionContext configured!
- 根据错误原理解决Hibernate运行出现No CurrentSessionContext configured!错误
- 小白日记_错误:org.hibernate.HibernateException: No CurrentSessionContext configured!
- 错误:org.hibernate.HibernateException:No CurrentSessionContext configured!
- 解决"No CurrentSessionContext configured"错误
- No CurrentSessionContext configured!" 异常解决方案
- org.hibernate.HibernateException: No CurrentSessionContext configured!
- org.hibernate.HibernateException: No CurrentSessionContext configured!
- Hibernate3.6:org.hibernate.HibernateException: No CurrentSessionContext configured!
- 【Hibernate学习杂记】No CurrentSessionContext configured!解决方法