春天默认的hibernate会话控制行为是什么? [英] What's the default hibernate session control behavior in spring?

查看:81
本文介绍了春天默认的hibernate会话控制行为是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用spring和hibernate(controller - > service - > dao)的3层应用程序,事务应用于服务层。我没有配置OpenSessionInViewInterceptor或OpenSessionInViewFilter,我想知道hibernate会话控制行为。每个交易或每个请求打开会话?如果您使用 docs / 3.0.x / javadoc-api / org / springframework / orm / hibernate3 / HibernateTransactionManager.htmlrel =noreferrer> HibernateTransactionManager ,a Session 会绑定到当前线程,并在事务结束时刷新和关闭,通过提交或回滚。



另见




I have a 3 layer application using spring and hibernate (controller -> service -> dao) and transaction is applied to service layer. I don't configure OpenSessionInViewInterceptor or OpenSessionInViewFilter and I want to know the hibernate session control behavior. Open session per transaction or per request? Thanks!

解决方案

If you're using the HibernateTransactionManager, a Session will get bound to the current thread and flushed and closed when the transaction ends, either through commit or roll back.

See also

这篇关于春天默认的hibernate会话控制行为是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆