6
6
using NHibernate . Engine ;
7
7
using NHibernate . Engine . Transaction ;
8
8
using NHibernate . Exceptions ;
9
- using NHibernate . Impl ;
10
9
11
10
namespace NHibernate . Transaction
12
11
{
@@ -16,7 +15,7 @@ namespace NHibernate.Transaction
16
15
/// </summary>
17
16
public partial class AdoNetTransactionFactory : ITransactionFactory
18
17
{
19
- private readonly INHibernateLogger isolaterLog = NHibernateLogger . For ( typeof ( ITransactionFactory ) ) ;
18
+ private readonly INHibernateLogger _isolatorLog = NHibernateLogger . For ( typeof ( ITransactionFactory ) ) ;
20
19
21
20
/// <inheritdoc />
22
21
public virtual ITransaction CreateTransaction ( ISessionImplementor session )
@@ -52,7 +51,6 @@ public virtual void ExecuteWorkInIsolation(ISessionImplementor session, IIsolate
52
51
53
52
DbConnection connection = null ;
54
53
DbTransaction trans = null ;
55
- // bool wasAutoCommit = false;
56
54
try
57
55
{
58
56
// We make an exception for SQLite and use the session's connection,
@@ -64,20 +62,13 @@ public virtual void ExecuteWorkInIsolation(ISessionImplementor session, IIsolate
64
62
if ( transacted )
65
63
{
66
64
trans = connection . BeginTransaction ( ) ;
67
- // TODO NH: a way to read the autocommit state is needed
68
- //if (TransactionManager.GetAutoCommit(connection))
69
- //{
70
- // wasAutoCommit = true;
71
- // TransactionManager.SetAutoCommit(connection, false);
72
- //}
73
65
}
74
66
75
67
work . DoWork ( connection , trans ) ;
76
68
77
69
if ( transacted )
78
70
{
79
71
trans . Commit ( ) ;
80
- //TransactionManager.Commit(connection);
81
72
}
82
73
}
83
74
catch ( Exception t )
@@ -93,46 +84,30 @@ public virtual void ExecuteWorkInIsolation(ISessionImplementor session, IIsolate
93
84
}
94
85
catch ( Exception ignore )
95
86
{
96
- isolaterLog . Debug ( ignore , "Unable to rollback transaction" ) ;
87
+ _isolatorLog . Debug ( ignore , "Unable to rollback transaction" ) ;
97
88
}
98
89
99
- if ( t is HibernateException )
90
+ switch ( t )
100
91
{
101
- throw ;
102
- }
103
- else if ( t is DbException )
104
- {
105
- throw ADOExceptionHelper . Convert ( session . Factory . SQLExceptionConverter , t ,
106
- "error performing isolated work" ) ;
107
- }
108
- else
109
- {
110
- throw new HibernateException ( "error performing isolated work" , t ) ;
92
+ case HibernateException _:
93
+ throw ;
94
+ case DbException _:
95
+ throw ADOExceptionHelper . Convert ( session . Factory . SQLExceptionConverter , t ,
96
+ "error performing isolated work" ) ;
97
+ default :
98
+ throw new HibernateException ( "error performing isolated work" , t ) ;
111
99
}
112
100
}
113
101
}
114
102
finally
115
103
{
116
- //if (transacted && wasAutoCommit)
117
- //{
118
- // try
119
- // {
120
- // // TODO NH: reset autocommit
121
- // // TransactionManager.SetAutoCommit(connection, true);
122
- // }
123
- // catch (Exception)
124
- // {
125
- // log.Debug("was unable to reset connection back to auto-commit");
126
- // }
127
- //}
128
-
129
104
try
130
105
{
131
106
trans ? . Dispose ( ) ;
132
107
}
133
108
catch ( Exception ignore )
134
109
{
135
- isolaterLog . Warn ( ignore , "Unable to dispose transaction" ) ;
110
+ _isolatorLog . Warn ( ignore , "Unable to dispose transaction" ) ;
136
111
}
137
112
138
113
if ( connection != null && session . Factory . Dialect is SQLiteDialect == false )
0 commit comments