什么是hibernate中的上下文会话? [英] What is contextual sessions in hibernate?
问题描述
- 什么是Hibernate中的上下文会话?
- 当我使用上下文会话实现接口创建和关闭会话时 $ b $将Hibernate的
-
JTASessionContext :当前会话由JTA事务进行跟踪和作用域。这里的处理过程与之前的仅适用于JTA的方法完全相同。详情请参阅Javadocs。
-
ThreadLocalSessionContext :当前会话由执行线程跟踪。详情请参阅Javadocs。
-
ManagedSessionContext :当前会话由执行线程跟踪。但是,您有责任使用此类上的静态方法绑定和取消绑定Session实例:它不会打开,刷新或关闭会话
- What is contextual session in Hibernate?
- When I created and closed a sessions in between use contextual session implementation interfaces?
JTASessionContext: current sessions are tracked and scoped by a JTA transaction. The processing here is exactly the same as in the older JTA-only approach. See the Javadocs for details.
ThreadLocalSessionContext: current sessions are tracked by thread of execution. See the Javadocs for details.
ManagedSessionContext: current sessions are tracked by thread of execution. However, you are responsible to bind and unbind a Session instance with static methods on this class: it does not open, flush, or close a Session
Contextual Session
想象成一个当前映射的映射。 上下文
。有时这个特定的案例被标记为 session-per-request
模型。 一个Hibernate接口 CurrentSessionContext 可以映射当前会话(例如 SessionFactory.getCurrentSession()
)到不同的上下文。这个接口有3个实现:
查看 Architecture Architecture Session 是Hibernate文档的一部分,以获得更多官方的详细信息。
Think of Hibernate's Contextual Session
as a mapping of a current Session to a user's Context.
For example: a single transaction could be such a context, hence if the Hibernate Session's lifecycle matches a life of this transaction, the Session could be called contextual, where a single transaction defines such a context
. Sometimes this particular case is labeled as a session-per-request
model.
A Hibernate interface CurrentSessionContext is there to map a current session ( e.g. SessionFactory.getCurrentSession()
) to different contexts. This interface has 3 implementations:
Take a look at the Architecture Current Session part of the Hibernate documentation for more "official" details.
这篇关于什么是hibernate中的上下文会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!