C# 클래스 Spring.Data.NHibernate.Support.SessionScope

Implementation of SessionScope that associates a single session within the using scope.

It is recommended to be used in the following type of scenario: using (new SessionScope()) { ... do multiple operation, possibly in multiple transactions. } At the end of "using", the session is automatically closed. All transactions within the scope use the same session, if you are using Spring's HibernateTemplate or using Spring's implementation of NHibernate 1.2's ICurrentSessionContext interface.

It is assumed that the session factory object name is called "SessionFactory". In case that you named the object in different way you can specify your can specify it in the application settings using the key Spring.Data.NHibernate.Support.SessionScope.SessionFactoryObjectName. Values for EntityInterceptorObjectName and SingleSessionMode can be specified similarly.

Note: The session is managed on a per thread basis on the thread that opens the scope instance. This means that you must never pass a reference to a SessionScope instance over to another thread!

상속: IDisposable
파일 보기 프로젝트 열기: spring-projects/spring-net 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
log ILog

공개 메소드들

메소드 설명
Close ( ) : void

Close the current view's session and unregisters from spring's TransactionSynchronizationManager.

Dispose ( ) : void

Call Close(),

Open ( ) : void

Opens a new session or participates in an existing session and registers with spring's TransactionSynchronizationManager.

SessionScope ( ) : System

Initializes a new instance of the SessionScope class in single session mode, associating a session with the thread. The session is opened lazily on demand.

SessionScope ( ISessionFactory sessionFactory, IInterceptor entityInterceptor, bool singleSession, FlushMode defaultFlushMode, bool open ) : System

Initializes a new instance of the SessionScope class.

SessionScope ( ISessionFactory sessionFactory, bool open ) : System

Initializes a new instance of the SessionScope class.

SessionScope ( Spring.Data.NHibernate.Support.SessionScopeSettings settings, bool open ) : System

Initializes a new instance of the SessionScope class.

SessionScope ( bool open ) : System

Initializes a new instance of the SessionScope class.

SessionScope ( string sectionName, Type namespaceType, bool open ) : System

Initializes a new instance of the SessionScope class.

SessionScope ( string sectionName, bool open ) : System

Initializes a new instance of the SessionScope class.

비공개 메소드들

메소드 설명
DoClose ( bool isLogDebugEnabled ) : void
DoOpenSession ( ) : ISession
SetOpen ( bool isOpen ) : void

Sets a flag, whether this scope is in "open" state on the current logical thread.

SetParticipating ( bool participating ) : void

Gets/Sets a flag, whether this scope manages it's own session for the current logical thread or not.

메소드 상세

Close() 공개 메소드

Close the current view's session and unregisters from spring's TransactionSynchronizationManager.
public Close ( ) : void
리턴 void

Dispose() 공개 메소드

Call Close(),
public Dispose ( ) : void
리턴 void

Open() 공개 메소드

Opens a new session or participates in an existing session and registers with spring's TransactionSynchronizationManager.
public Open ( ) : void
리턴 void

SessionScope() 공개 메소드

Initializes a new instance of the SessionScope class in single session mode, associating a session with the thread. The session is opened lazily on demand.
public SessionScope ( ) : System
리턴 System

SessionScope() 공개 메소드

Initializes a new instance of the SessionScope class.
public SessionScope ( ISessionFactory sessionFactory, IInterceptor entityInterceptor, bool singleSession, FlushMode defaultFlushMode, bool open ) : System
sessionFactory ISessionFactory /// The instance to be used for obtaining instances. ///
entityInterceptor IInterceptor /// Specify the to be set on each session provided by this instance. ///
singleSession bool /// Set whether to use a single session for each request. See property for details. ///
defaultFlushMode FlushMode /// Specify the flushmode to be applied on each session provided by this instance. ///
open bool /// If set to true associate a session with the thread. If false, another /// collaborating class will associate the session with the thread, potentially by calling /// the Open method on this class. ///
리턴 System

SessionScope() 공개 메소드

Initializes a new instance of the SessionScope class.
public SessionScope ( ISessionFactory sessionFactory, bool open ) : System
sessionFactory ISessionFactory /// The instance to be used for obtaining instances. ///
open bool /// If set to true associate a session with the thread. If false, another /// collaborating class will associate the session with the thread, potentially by calling /// the Open method on this class. ///
리턴 System

SessionScope() 공개 메소드

Initializes a new instance of the SessionScope class.
public SessionScope ( Spring.Data.NHibernate.Support.SessionScopeSettings settings, bool open ) : System
settings Spring.Data.NHibernate.Support.SessionScopeSettings An instance holding the scope configuration
open bool /// If set to true associate a session with the thread. If false, another /// collaborating class will associate the session with the thread, potentially by calling /// the Open method on this class. ///
리턴 System

SessionScope() 공개 메소드

Initializes a new instance of the SessionScope class.
public SessionScope ( bool open ) : System
open bool /// If set to true associate a session with the thread. If false, another /// collaborating class will associate the session with the thread, potentially by calling /// the Open method on this class. ///
리턴 System

SessionScope() 공개 메소드

Initializes a new instance of the SessionScope class.
public SessionScope ( string sectionName, Type namespaceType, bool open ) : System
sectionName string /// The name of the configuration section to read configuration settings from. /// See for more info. ///
namespaceType System.Type The type, who's full name is used for prefixing appSetting keys
open bool /// If set to true associate a session with the thread. If false, another /// collaborating class will associate the session with the thread, potentially by calling /// the Open method on this class. ///
리턴 System

SessionScope() 공개 메소드

Initializes a new instance of the SessionScope class.
public SessionScope ( string sectionName, bool open ) : System
sectionName string /// The name of the configuration section to read configuration settings from. /// See for more info. ///
open bool /// If set to true associate a session with the thread. If false, another /// collaborating class will associate the session with the thread, potentially by calling /// the Open method on this class. ///
리턴 System

프로퍼티 상세

log 보호되어 있는 프로퍼티

The logging instance.
protected ILog log
리턴 ILog