当前线程
重要
Hibernate offers three methods of current session tracking. The "thread" based method is not intended for production use; it is merely useful for prototyping and tutorials such as this one. Current session tracking is discussed in more detail later on.
3个方法
A org.hibernate.Session
begins when the first call to getCurrentSession()
is made for the current thread. It is then bound by Hibernate to the
current thread. When the transaction ends, either through commit or
rollback, Hibernate automatically unbinds the org.hibernate.Session
from the thread and closes it for you. If you call getCurrentSession()
again, you get a new org.hibernate.Session
and can start a new unit of work.
新会话
本文解释了SessionFactory.getCurrentSession()方法的功能及其在Hibernate中的作用。该方法返回当前的工作单元,并且由于配置选项设置为thread,当前工作单元的上下文绑定到执行应用程序的当前Java线程。文章还介绍了如何开始和结束一个会话,以及如何跟踪当前会话的三种方法。
1177

被折叠的 条评论
为什么被折叠?



