休眠:没有配置CurrentSessionContext [英] Hibernate: No CurrentSessionContext configured
问题描述
$ b
HibernateException:No
配置了CurrentSessionContext!
blockquote>
在我的代码中。返回的其他搜索的唯一信息是罪魁祸首是:
< property name =current_session_context_class>线程< /性>
在我的hibernate.cfg.xml中。我确实在我的hibernate.cfg.xml文件中有这个,并且我正在Tomcat 6中运行它。有人知道其他可能的原因吗?
>我相信你需要设置你的current_session_context_class为一个实际的类...我有我的hibernate.cfg.xml配置为如下:
< property name =hibernate.current_session_context_class> org.hibernate.context.ThreadLocalSessionContext< / property>
上面的代码用于mySql数据库,但我不认为它关系到数据库的类型是为上述财产
希望这有助于
I keep getting a :
HibernateException: No CurrentSessionContext configured!
in my code. The only information other searches that returned is that the culprit is:
<property name="current_session_context_class">thread</property>
in my hibernate.cfg.xml. I do have that in my hibernate.cfg.xml file, and I am running this in Tomcat 6. Does anyone know other possible causes?
解决方案I believe you need to set your current_session_context_class to an actual class...I have my hibernate.cfg.xml configured for that as follows:
<property name="hibernate.current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</property>
The above code is used for a mySql database but i don't think it matters what type the database is for the above property
Hope this helps
这篇关于休眠:没有配置CurrentSessionContext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!