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

------解决方案--------------------
确保事务拦截到这个方法了。
------解决方案--------------------
getCurentSession这种写法必须绑定事务,不然会报错。所以你需要添加配置:
<property name="hibernate.current_session_context_class">thread</property>
使用过程中,需要开启事务,不然不建议这种用法,只好用openSession!
参考:http://blog.****.net/loveyout/article/details/4193894
spring配置
------解决方案--------------------
确保事务拦截到这个方法了。
------解决方案--------------------
getCurentSession这种写法必须绑定事务,不然会报错。所以你需要添加配置:
<property name="hibernate.current_session_context_class">thread</property>
使用过程中,需要开启事务,不然不建议这种用法,只好用openSession!
参考:http://blog.****.net/loveyout/article/details/4193894