@@ -8,6 +8,7 @@ namespace NHibernate.Context
88{
99 //TODO: refactoring on this class. Maybe using MapBasedSessionContext.
1010 /// <summary>
11+ /// <para>
1112 /// A <see cref="ICurrentSessionContext"/> impl which scopes the notion of current
1213 /// session by the current thread of execution. Threads do not give us a
1314 /// nice hook to perform any type of cleanup making
@@ -19,13 +20,15 @@ namespace NHibernate.Context
1920 /// generated here are unusable until after {@link Session#beginTransaction()}
2021 /// has been called. If <tt>Close()</tt> is called on a session managed by
2122 /// this class, it will be automatically unbound.
22- /// <p/>
23+ /// </para>
24+ /// <para>
2325 /// Additionally, the static <see cref="Bind"/> and <see cref="Unbind"/> methods are
2426 /// provided to allow application code to explicitly control opening and
2527 /// closing of these sessions. This, with some from of interception,
2628 /// is the preferred approach. It also allows easy framework integration
2729 /// and one possible approach for implementing long-sessions.
28- /// <p/>
30+ /// </para>
31+ /// <para>The cleanup on transaction end is indeed not implemented.</para>
2932 /// </summary>
3033 [ Serializable ]
3134 public class ThreadLocalSessionContext : ICurrentSessionContext
@@ -148,23 +151,28 @@ private bool NeedsWrapping(ISession current)
148151
149152 protected ISession BuildOrObtainSession ( )
150153 {
151- return factory . OpenSession (
152- null ,
153- IsAutoFlushEnabled ( ) ,
154- IsAutoCloseEnabled ( ) ,
155- GetConnectionReleaseMode ( ) ) ;
154+ return factory . WithOptions ( )
155+ . AutoClose ( IsAutoCloseEnabled ( ) )
156+ . ConnectionReleaseMode ( GetConnectionReleaseMode ( ) )
157+ . OpenSession ( ) ;
156158 }
157159
158160 private ConnectionReleaseMode GetConnectionReleaseMode ( )
159161 {
160162 return factory . Settings . ConnectionReleaseMode ;
161163 }
162164
165+ /// <summary>
166+ /// Not currently implemented.
167+ /// </summary>
168+ /// <returns><see langword="true"/></returns>
163169 protected virtual bool IsAutoCloseEnabled ( )
164170 {
165171 return true ;
166172 }
167173
174+ // Obsolete since v5
175+ [ Obsolete ( "Had never any implementation, has always had no effect." ) ]
168176 protected virtual bool IsAutoFlushEnabled ( )
169177 {
170178 return true ;
0 commit comments