SessionFactoryUtils.DoGetSession Method
Spring.NET 1.3.0 RC1 for .NET 2.0 API Reference

SessionFactoryUtils.DoGetSession Method

Get a Hibernate Session for the given SessionFactory.

[Visual Basic]
Public Shared Sub DoGetSession( _
   ByVal sessionFactory As ISessionFactory, _
   ByVal allowCreate As Boolean _
public static ISession DoGetSession(
   ISessionFactory sessionFactory,
   bool allowCreate


The session factory.
if set to true [allow create].

Return Value

The Hibernate Session


Is aware of and will return any existing corresponding Session bound to the current thread, for example whenusing HibernateTransactionManager. Will create a new Session otherwise, if "allowCreate" is true.

Throws the orginal HibernateException, in contrast to GetSession.


Exception Type Condition
HibernateException 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