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
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
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