类 JTASessionContext
- java.lang.Object
-
- org.hibernate.context.spi.AbstractCurrentSessionContext
-
- org.hibernate.context.internal.JTASessionContext
-
- 所有已实现的接口:
Serializable,CurrentSessionContext
public class JTASessionContext extends AbstractCurrentSessionContext
An implementation ofCurrentSessionContextwhich scopes the notion of a current session to a JTA transaction. Because JTA gives us a nice tie-in to clean up after ourselves, this implementation will generate Sessions as needed provided a JTA transaction is in effect. If a session is not already associated with the current JTA transaction at the timecurrentSession()is called, a new session will be opened and it will be associated with that JTA transaction. Note that the sessions returned from this method are automatically configured with both theauto-flushandauto-closeattributes set to true, meaning that the Session will be automatically flushed and closed as part of the lifecycle for the JTA transaction to which it is associated. Additionally, it will also be configured to aggressively release JDBC connections after each statement is executed. These settings are governed by theisAutoFlushEnabled(),isAutoCloseEnabled(), andgetConnectionReleaseMode()methods; these are provided (along with thebuildOrObtainSession()method) for easier subclassing for custom JTA-based session tracking logic (like maybe long-session semantics).- 作者:
- Steve Ebersole
- 另请参阅:
- 序列化表格
-
-
嵌套类概要
嵌套类 修饰符和类型 类 说明 protected static classJTASessionContext.CleanupSyncJTA transaction sync used for cleanup of the internal session map.
-
构造器概要
构造器 构造器 说明 JTASessionContext(SessionFactoryImplementor factory)Constructs a JTASessionContext
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected SessionbuildOrObtainSession()Strictly provided for subclassing purposes; specifically to allow long-session support.SessioncurrentSession()Retrieve the current session according to the scoping defined by this implementation.protected ConnectionReleaseModegetConnectionReleaseMode()Mainly for subclass usage.protected booleanisAutoCloseEnabled()Mainly for subclass usage.protected booleanisAutoFlushEnabled()Mainly for subclass usage.-
从类继承的方法 org.hibernate.context.spi.AbstractCurrentSessionContext
baseSessionBuilder, factory, validateExistingSession
-
-
-
-
构造器详细资料
-
JTASessionContext
public JTASessionContext(SessionFactoryImplementor factory)
Constructs a JTASessionContext- 参数:
factory- The factory this context will service
-
-
方法详细资料
-
currentSession
public Session currentSession() throws HibernateException
从接口复制的说明:CurrentSessionContextRetrieve the current session according to the scoping defined by this implementation.- 返回:
- The current session.
- 抛出:
HibernateException- Typically indicates an issue locating or creating the current session.
-
buildOrObtainSession
protected Session buildOrObtainSession()
Strictly provided for subclassing purposes; specifically to allow long-session support. This implementation always just opens a new session.- 返回:
- the built or (re)obtained session.
-
isAutoCloseEnabled
protected boolean isAutoCloseEnabled()
Mainly for subclass usage. This impl always returns true.- 返回:
- Whether or not the the session should be closed by transaction completion.
-
isAutoFlushEnabled
protected boolean isAutoFlushEnabled()
Mainly for subclass usage. This impl always returns true.- 返回:
- Whether or not the the session should be flushed prior transaction completion.
-
getConnectionReleaseMode
protected ConnectionReleaseMode getConnectionReleaseMode()
Mainly for subclass usage. This impl always returns after_statement.- 返回:
- The connection release mode for any built sessions.
-
-