A
ICurrentSessionContext impl which scopes the notion of current
session by the current thread of execution. Threads do not give us a
nice hook to perform any type of cleanup making
it questionable for this impl to actually generate Session instances. In
the interest of usability, it was decided to have this default impl
actually generate a session upon first request and then clean it up
after the
ITransaction associated with that session
is committed/rolled-back. In order for ensuring that happens, the sessions
generated here are unusable until after {@link Session#beginTransaction()}
has been called. If Close() is called on a session managed by
this class, it will be automatically unbound.
Additionally, the static
Bind(ISession) and
Unbind(ISessionFactory) methods are
provided to allow application code to explicitly control opening and
closing of these sessions. This, with some from of interception,
is the preferred approach. It also allows easy framework integration
and one possible approach for implementing long-sessions.
Namespace: NHibernate.ContextAssembly: NHibernate (in NHibernate.dll) Version: 3.2.0.4000 (3.2.0.4000)
Syntax
Inheritance Hierarchy
See Also