读书人

spring+hibernate 经过配置sessionFac

发布时间: 2013-07-20 11:07:48 作者: rapoo

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

读书人网 >Java Web开发

热点推荐