Spring.NET 1.3.0 RC1 for .NET 2.0 API Reference

SessionFactoryUtils.GetSession(ISessionFactory, Boolean) 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 create a new Session otherwise, if allowCreate is true.

[Visual Basic]
Public Overloads Shared Sub GetSession( _
   ByVal sessionFactory As ISessionFactory, _
   ByVal allowCreate As Boolean _
)
[C#]
public static ISession GetSession(
   ISessionFactory sessionFactory,
   bool allowCreate
);

Parameters

sessionFactory
The session factory to create the session with.
allowCreate
if set to true create a non-transactional Session when no transactional Session can be found for the current thread.

Return Value

The hibernate session

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