首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

spring+hibernate 经过配置sessionFactory 使用getCurentSession 报错 openSession正常求指教

2013-07-20 
spring+hibernate 通过配置sessionFactory 使用getCurentSession 报错 openSession正常求指教spring配置[

spring+hibernate 通过配置sessionFactory 使用getCurentSession 报错 openSession正常求指教
spring配置
spring+hibernate 经过配置sessionFactory 使用getCurentSession 报错 openSession正常求指教spring+hibernate 经过配置sessionFactory 使用getCurentSession 报错 openSession正常求指教
[解决办法]
确保事务拦截到这个方法了。
[解决办法]
getCurentSession这种写法必须绑定事务,不然会报错。所以你需要添加配置:
<property name="hibernate.current_session_context_class">thread</property>

使用过程中,需要开启事务,不然不建议这种用法,只好用openSession!

参考:http://blog.csdn.net/loveyout/article/details/4193894

热点排行