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 _
)
[C#]
public static ISession DoGetSession(
   ISessionFactory sessionFactory,
   bool allowCreate
);

Parameters

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

Return Value

The Hibernate Session

Remarks

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.

Exceptions

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