C# Class CAESDO.Recruitment.Data.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.
Afficher le fichier Open project: ucdavis/Recruitments

Private Properties

Свойство Type Description
GetSession ISession
InitSessionFactory void
IsInWebContext bool
NHibernateSessionManager System.Runtime.Remoting.Messaging

Méthodes publiques

Méthode Description
BeginTransaction ( ) : void
CloseSession ( ) : void
CommitTransaction ( ) : void
EnsureFreshness ( object o ) : void

Make sure the object given is connected to the current session

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

Allows you to register an interceptor on a new session. This may not be called if there is already an open session attached to the HttpContext. If you have an interceptor to be used, modify the HttpModule to call this before calling BeginTransaction().

RollbackTransaction ( ) : void

Private Methods

Méthode Description
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.

Method Details

BeginTransaction() public méthode

public BeginTransaction ( ) : void
Résultat void

CloseSession() public méthode

public CloseSession ( ) : void
Résultat void

CommitTransaction() public méthode

public CommitTransaction ( ) : void
Résultat void

EnsureFreshness() public méthode

Make sure the object given is connected to the current session
public EnsureFreshness ( object o ) : void
o object Mapped Object
Résultat void

GetSession() public méthode

public GetSession ( ) : ISession
Résultat ISession

HasOpenTransaction() public méthode

public HasOpenTransaction ( ) : bool
Résultat bool

RegisterInterceptor() public méthode

Allows you to register an interceptor on a new session. This may not be called if there is already an open session attached to the HttpContext. If you have an interceptor to be used, modify the HttpModule to call this before calling BeginTransaction().
public RegisterInterceptor ( IInterceptor interceptor ) : void
interceptor IInterceptor
Résultat void

RollbackTransaction() public méthode

public RollbackTransaction ( ) : void
Résultat void