Spring.NET 1.3.0 RC1 for .NET 2.0 API Reference

SessionFactoryUtils.GetSession(ISessionFactory, IInterceptor, IAdoExceptionTranslator) Method

Get a Hibernate Session for the given SessionFactory. Is aware of and will return any existing corresponding Session bound to the current thread, for example when using HibernateTransactionManager. Will always create a new Session otherwise.

[Visual Basic]
Public Overloads Shared Sub GetSession( _
   ByVal sessionFactory As ISessionFactory, _
   ByVal entityInterceptor As IInterceptor, _
   ByVal adoExceptionTranslator As IAdoExceptionTranslator _
public static ISession GetSession(
   ISessionFactory sessionFactory,
   IInterceptor entityInterceptor,
   IAdoExceptionTranslator adoExceptionTranslator


The session factory to create the session with.
Hibernate entity interceptor, or
if none.
AdoExceptionTranslator to use for flushing the Session on transaction synchronization (can be
; only used when actually registering a transaction synchronization).

Return Value

The Hibernate Session


Supports setting a Session-level Hibernate entity interceptor that allows to inspect and change property values before writing to and reading from the database. Such an interceptor can also be set at the SessionFactory level (i.e. on LocalSessionFactoryObject), on HibernateTransactionManager, or on HibernateInterceptor/HibernateTemplate.


Exception Type Condition
DataAccessResourceFailureException If the session couldn't be created.
InvalidOperationException If no thread-bound Session found and allowCreate is false.

See Also

SessionFactoryUtils Class | Spring.Data.NHibernate Namespace | SessionFactoryUtils.GetSession Overload List