1
1
using System ;
2
2
using System . Collections ;
3
3
using System . Collections . Generic ;
4
- using System . Data ;
5
4
using System . Data . Common ;
6
5
using System . Linq . Expressions ;
7
6
using System . Runtime . Serialization ;
@@ -56,8 +55,6 @@ public sealed partial class SessionImpl : AbstractSessionImpl, IEventSource, ISe
56
55
[ NonSerialized ]
57
56
private int _suspendAutoFlushCount ;
58
57
59
- private readonly ConnectionManager connectionManager ;
60
-
61
58
[ NonSerialized ]
62
59
private readonly IDictionary < string , IFilter > enabledFilters = new Dictionary < string , IFilter > ( ) ;
63
60
@@ -71,8 +68,6 @@ public sealed partial class SessionImpl : AbstractSessionImpl, IEventSource, ISe
71
68
private readonly bool autoCloseSessionEnabled ;
72
69
[ NonSerialized ]
73
70
private readonly ConnectionReleaseMode connectionReleaseMode ;
74
- [ NonSerialized ]
75
- private readonly bool _transactionCoordinatorShared ;
76
71
77
72
#region System.Runtime.Serialization.ISerializable Members
78
73
@@ -104,7 +99,7 @@ private SessionImpl(SerializationInfo info, StreamingContext context)
104
99
enabledFilters = ( IDictionary < string , IFilter > ) info . GetValue ( "enabledFilters" , typeof ( Dictionary < string , IFilter > ) ) ;
105
100
enabledFilterNames = ( List < string > ) info . GetValue ( "enabledFilterNames" , typeof ( List < string > ) ) ;
106
101
107
- connectionManager = ( ConnectionManager ) info . GetValue ( "connectionManager" , typeof ( ConnectionManager ) ) ;
102
+ ConnectionManager = ( ConnectionManager ) info . GetValue ( "connectionManager" , typeof ( ConnectionManager ) ) ;
108
103
}
109
104
110
105
/// <summary>
@@ -122,11 +117,11 @@ void ISerializable.GetObjectData(SerializationInfo info, StreamingContext contex
122
117
{
123
118
log . Debug ( "writting session to serializer" ) ;
124
119
125
- if ( ! connectionManager . IsReadyForSerialization )
120
+ if ( ! ConnectionManager . IsReadyForSerialization )
126
121
{
127
122
throw new InvalidOperationException ( "Cannot serialize a Session while connected" ) ;
128
123
}
129
- if ( _transactionCoordinatorShared )
124
+ if ( TransactionCoordinatorShared )
130
125
{
131
126
throw new InvalidOperationException ( "Cannot serialize a Session sharing its transaction coordinator" ) ;
132
127
}
@@ -143,7 +138,7 @@ void ISerializable.GetObjectData(SerializationInfo info, StreamingContext contex
143
138
info . AddValue ( "enabledFilters" , enabledFilters , typeof ( IDictionary < string , IFilter > ) ) ;
144
139
info . AddValue ( "enabledFilterNames" , enabledFilterNames , typeof ( List < string > ) ) ;
145
140
146
- info . AddValue ( "connectionManager" , connectionManager , typeof ( ConnectionManager ) ) ;
141
+ info . AddValue ( "connectionManager" , ConnectionManager , typeof ( ConnectionManager ) ) ;
147
142
}
148
143
149
144
#endregion
@@ -194,21 +189,6 @@ internal SessionImpl(SessionFactoryImpl factory, ISessionCreationOptions options
194
189
listeners = factory . EventListeners ;
195
190
connectionReleaseMode = options . SessionConnectionReleaseMode ;
196
191
197
- if ( options is ISharedSessionCreationOptions sharedOptions && sharedOptions . IsTransactionCoordinatorShared )
198
- {
199
- // NH specific implementation: need to port Hibernate transaction management.
200
- _transactionCoordinatorShared = true ;
201
- if ( options . UserSuppliedConnection != null )
202
- throw new SessionException ( "Cannot simultaneously share transaction context and specify connection" ) ;
203
- connectionManager = sharedOptions . ConnectionManager ;
204
- connectionManager . AddDependentSession ( this ) ;
205
- }
206
- else
207
- {
208
- connectionManager = new ConnectionManager (
209
- this , options . UserSuppliedConnection , connectionReleaseMode , Interceptor , options . ShouldAutoJoinTransaction ) ;
210
- }
211
-
212
192
if ( factory . Statistics . IsStatisticsEnabled )
213
193
{
214
194
factory . StatisticsImplementor . OpenSession ( ) ;
@@ -255,7 +235,7 @@ public override IBatcher Batcher
255
235
get
256
236
{
257
237
CheckAndUpdateSessionStatus ( ) ;
258
- return connectionManager . Batcher ;
238
+ return ConnectionManager . Batcher ;
259
239
}
260
240
}
261
241
@@ -298,9 +278,9 @@ public DbConnection Close()
298
278
299
279
try
300
280
{
301
- if ( ! _transactionCoordinatorShared )
302
- return connectionManager . Close ( ) ;
303
- connectionManager . RemoveDependentSession ( this ) ;
281
+ if ( ! TransactionCoordinatorShared )
282
+ return ConnectionManager . Close ( ) ;
283
+ ConnectionManager . RemoveDependentSession ( this ) ;
304
284
return null ;
305
285
}
306
286
finally
@@ -1319,39 +1299,9 @@ public void Refresh(object obj, LockMode lockMode)
1319
1299
}
1320
1300
}
1321
1301
1322
- public ITransaction BeginTransaction ( IsolationLevel isolationLevel )
1323
- {
1324
- using ( BeginProcess ( ) )
1325
- {
1326
- if ( _transactionCoordinatorShared )
1327
- {
1328
- // Todo : should seriously consider not allowing a txn to begin from a child session
1329
- // can always route the request to the root session...
1330
- log . Warn ( "Transaction started on non-root session" ) ;
1331
- }
1332
-
1333
- return connectionManager . BeginTransaction ( isolationLevel ) ;
1334
- }
1335
- }
1336
-
1337
- public ITransaction BeginTransaction ( )
1338
- {
1339
- using ( BeginProcess ( ) )
1340
- {
1341
- if ( _transactionCoordinatorShared )
1342
- {
1343
- // Todo : should seriously consider not allowing a txn to begin from a child session
1344
- // can always route the request to the root session...
1345
- log . Warn ( "Transaction started on non-root session" ) ;
1346
- }
1347
-
1348
- return connectionManager . BeginTransaction ( ) ;
1349
- }
1350
- }
1351
-
1352
1302
public ITransaction Transaction
1353
1303
{
1354
- get { return connectionManager . Transaction ; }
1304
+ get { return ConnectionManager . Transaction ; }
1355
1305
}
1356
1306
1357
1307
/// <summary>
@@ -1507,7 +1457,7 @@ public override void InitializeCollection(IPersistentCollection collection, bool
1507
1457
1508
1458
public override DbConnection Connection
1509
1459
{
1510
- get { return connectionManager . GetConnection ( ) ; }
1460
+ get { return ConnectionManager . GetConnection ( ) ; }
1511
1461
}
1512
1462
1513
1463
/// <summary>
@@ -1523,7 +1473,7 @@ public override DbConnection Connection
1523
1473
/// </remarks>
1524
1474
public override bool IsConnected
1525
1475
{
1526
- get { return connectionManager . IsConnected ; }
1476
+ get { return ConnectionManager . IsConnected ; }
1527
1477
}
1528
1478
1529
1479
/// <summary></summary>
@@ -1532,7 +1482,7 @@ public DbConnection Disconnect()
1532
1482
using ( BeginProcess ( ) )
1533
1483
{
1534
1484
log . Debug ( "disconnecting session" ) ;
1535
- return connectionManager . Disconnect ( ) ;
1485
+ return ConnectionManager . Disconnect ( ) ;
1536
1486
}
1537
1487
}
1538
1488
@@ -1541,7 +1491,7 @@ public void Reconnect()
1541
1491
using ( BeginProcess ( ) )
1542
1492
{
1543
1493
log . Debug ( "reconnecting session" ) ;
1544
- connectionManager . Reconnect ( ) ;
1494
+ ConnectionManager . Reconnect ( ) ;
1545
1495
}
1546
1496
}
1547
1497
@@ -1550,7 +1500,7 @@ public void Reconnect(DbConnection conn)
1550
1500
using ( BeginProcess ( ) )
1551
1501
{
1552
1502
log . Debug ( "reconnecting session" ) ;
1553
- connectionManager . Reconnect ( conn ) ;
1503
+ ConnectionManager . Reconnect ( conn ) ;
1554
1504
}
1555
1505
}
1556
1506
@@ -2038,11 +1988,6 @@ private string[] ParseFilterParameterName(string filterParameterName)
2038
1988
return new [ ] { filterName , parameterName } ;
2039
1989
}
2040
1990
2041
- public override ConnectionManager ConnectionManager
2042
- {
2043
- get { return connectionManager ; }
2044
- }
2045
-
2046
1991
public IMultiQuery CreateMultiQuery ( )
2047
1992
{
2048
1993
using ( BeginProcess ( ) )
0 commit comments