【发布时间】:2011-02-02 04:07:37
【问题描述】:
只是想知道在 Hibernate 中开始一个新事务是否实际上分配了一个到数据库的连接?
我担心 b/c 我们的服务器会为收到的每个请求开始一个新事务,即使该请求不与数据库交互。我们将数据库连接视为主要瓶颈,所以我想知道是否应该花时间缩小我的事务范围。
到处搜索,并没有找到一个好的答案。非常简单的代码在这里:
SessionFactory sessionFactory = (SessionFactory) Context.getContext().getBean("sessionFactory");
sessionFactory.getCurrentSession().beginTransaction();
sessionFactory.getCurrentSession().setFlushMode(FlushMode.AUTO);
非常感谢! 一个
【问题讨论】:
标签: java performance hibernate orm transactions