C# 클래스 Customer.Project.DataAccess.NHibernateHelpers.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.
파일 보기 프로젝트 열기: atosorigin/AtosMvcStarterKit

Private Properties

프로퍼티 타입 설명
AutoMappings ISessionFactory
BeginTransaction void
GetSession ISession
IsInWebContext bool
NHibernateSessionManager System

공개 메소드들

메소드 설명
BeginTransaction ( ) : void

Begins the transaction.

CloseSession ( ) : void

Closes the session.

CloseSessionFactory ( ) : void

Closes the session and the disposes the session factory

CommitTransaction ( ) : void

Commits the transaction / Unit of Work if autocommit is set to true, canceltransaction to false and if the transaction is not committed or rolled back yet

ExportDatabaseSchema ( ) : void

Exports the database schema.

GetSession ( ) : ISession

Gets the session.

ImportDatabaseSchema ( ) : void

Imports the database schema.

InitSessionFactory ( ) : void
InitSessionFactory ( string xmlConfigFile ) : void

Inits the session factory.

OpenNewSession ( ) : ISession
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

Rollbacks the transaction.

비공개 메소드들

메소드 설명
AutoMappings ( ) : ISessionFactory
BeginTransaction ( ISession session ) : void
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.

IsInWebContext ( ) : bool
NHibernateSessionManager ( ) : System

Initializes the NHibernate session factory upon instantiation.

메소드 상세

BeginTransaction() 공개 메소드

Begins the transaction.
public BeginTransaction ( ) : void
리턴 void

CloseSession() 공개 메소드

Closes the session.
public CloseSession ( ) : void
리턴 void

CloseSessionFactory() 공개 메소드

Closes the session and the disposes the session factory
public CloseSessionFactory ( ) : void
리턴 void

CommitTransaction() 공개 메소드

Commits the transaction / Unit of Work if autocommit is set to true, canceltransaction to false and if the transaction is not committed or rolled back yet
public CommitTransaction ( ) : void
리턴 void

ExportDatabaseSchema() 공개 메소드

Exports the database schema.
public ExportDatabaseSchema ( ) : void
리턴 void

GetSession() 공개 메소드

Gets the session.
public GetSession ( ) : ISession
리턴 ISession

ImportDatabaseSchema() 공개 메소드

Imports the database schema.
public ImportDatabaseSchema ( ) : void
리턴 void

InitSessionFactory() 공개 메소드

public InitSessionFactory ( ) : void
리턴 void

InitSessionFactory() 공개 메소드

Inits the session factory.
public InitSessionFactory ( string xmlConfigFile ) : void
xmlConfigFile string
리턴 void

OpenNewSession() 공개 메소드

public OpenNewSession ( ) : ISession
리턴 ISession

RegisterInterceptor() 공개 메소드

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
리턴 void

RollbackTransaction() 공개 메소드

Rollbacks the transaction.
public RollbackTransaction ( ) : void
리턴 void