C# Класс UCDArch.Data.NHibernate.NHibernateSessionManager

Handles creation and management of sessions and transactions. It is a singleton because building the initial session factory is very expensive. Inspiration for this class came from Chapter 8 of Hibernate in Action by Bauer and King. Although it is a sealed singleton you can use TypeMock (http://www.typemock.com) for more flexible testing.
Показать файл Открыть проект

Private Properties

Свойство Тип Описание
GetSession ISession
InitSessionFactory void
IsInWebContext bool
NHibernateSessionManager System.Runtime.Remoting.Messaging

Открытые методы

Метод Описание
BeginTransaction ( ) : void
CloseSession ( ) : void
CommitTransaction ( ) : void
EnsureFreshness ( object o ) : void

Make sure the object given is connected to the current session

GetSession ( ) : ISession

Shortcut which just calls into the GetSession overload with the current registered interceptor. If no interceptor has been registered, it will be null

HasOpenTransaction ( ) : bool
RegisterInterceptor ( IInterceptor interceptor ) : void

Allows you to set the interceptor which will be used in all subsequent sessions

RollbackTransaction ( ) : void
SetFlushMode ( FlushMode flushMode ) : void

Allows you to set the flush mode which will be used with all sessions

Приватные методы

Метод Описание
GetSession ( IInterceptor interceptor ) : ISession

Gets a session with or without an interceptor. This method is not called directly; instead, it gets invoked from other public methods.

InitSessionFactory ( ) : void
IsInWebContext ( ) : bool
NHibernateSessionManager ( ) : System.Runtime.Remoting.Messaging

Initializes the NHibernate session factory upon instantiation.

Описание методов

BeginTransaction() публичный Метод

public BeginTransaction ( ) : void
Результат void

CloseSession() публичный Метод

public CloseSession ( ) : void
Результат void

CommitTransaction() публичный Метод

public CommitTransaction ( ) : void
Результат void

EnsureFreshness() публичный Метод

Make sure the object given is connected to the current session
public EnsureFreshness ( object o ) : void
o object Mapped Object
Результат void

GetSession() публичный Метод

Shortcut which just calls into the GetSession overload with the current registered interceptor. If no interceptor has been registered, it will be null
public GetSession ( ) : ISession
Результат ISession

HasOpenTransaction() публичный Метод

public HasOpenTransaction ( ) : bool
Результат bool

RegisterInterceptor() публичный Метод

Allows you to set the interceptor which will be used in all subsequent sessions
public RegisterInterceptor ( IInterceptor interceptor ) : void
interceptor IInterceptor
Результат void

RollbackTransaction() публичный Метод

public RollbackTransaction ( ) : void
Результат void

SetFlushMode() публичный Метод

Allows you to set the flush mode which will be used with all sessions
public SetFlushMode ( FlushMode flushMode ) : void
flushMode FlushMode
Результат void