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 _
)
[C#]
public static ISession GetSession(
   ISessionFactory sessionFactory,
   IInterceptor entityInterceptor,
   IAdoExceptionTranslator adoExceptionTranslator
);

Parameters

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

Return Value

The Hibernate Session

Remarks

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.

Exceptions

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