Skip to content

Commit 899bc77

Browse files
committed
Regenerate with latest version
1 parent 0e04aae commit 899bc77

30 files changed

+521
-287
lines changed

src/NHibernate/Async/Action/EntityDeleteAction.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,26 @@ private async Task<bool> PreDeleteAsync()
120120
return veto;
121121
}
122122

123-
protected override async Task AfterTransactionCompletionProcessImplAsync(bool success)
123+
protected override Task AfterTransactionCompletionProcessImplAsync(bool success)
124124
{
125-
if (Persister.HasCache)
125+
try
126126
{
127-
CacheKey ck = Session.GenerateCacheKey(Id, Persister.IdentifierType, Persister.RootEntityName);
128-
Persister.Cache.Release(ck, sLock);
127+
if (Persister.HasCache)
128+
{
129+
CacheKey ck = Session.GenerateCacheKey(Id, Persister.IdentifierType, Persister.RootEntityName);
130+
Persister.Cache.Release(ck, sLock);
131+
}
132+
133+
if (success)
134+
{
135+
return PostCommitDeleteAsync();
136+
}
137+
138+
return Task.CompletedTask;
129139
}
130-
if (success)
140+
catch (Exception ex)
131141
{
132-
await (PostCommitDeleteAsync()).ConfigureAwait(false);
142+
return Task.FromException<object>(ex);
133143
}
134144
}
135145

src/NHibernate/Async/Action/EntityIdentityInsertAction.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,26 @@ private async Task<bool> PreInsertAsync()
110110
return veto;
111111
}
112112

113-
protected override async Task AfterTransactionCompletionProcessImplAsync(bool success)
113+
protected override Task AfterTransactionCompletionProcessImplAsync(bool success)
114114
{
115-
//TODO Make 100% certain that this is called before any subsequent ScheduledUpdate.afterTransactionCompletion()!!
116-
//TODO from H3.2: reenable if we also fix the above todo
117-
/*EntityPersister persister = getEntityPersister();
115+
try
116+
{
117+
//TODO Make 100% certain that this is called before any subsequent ScheduledUpdate.afterTransactionCompletion()!!
118+
//TODO from H3.2: reenable if we also fix the above todo
119+
/*EntityPersister persister = getEntityPersister();
118120
if ( success && persister.hasCache() && !persister.isCacheInvalidationRequired() ) {
119121
persister.getCache().afterInsert( getGeneratedId(), cacheEntry );
120122
}*/
121-
if (success)
123+
if (success)
124+
{
125+
return PostCommitInsertAsync();
126+
}
127+
128+
return Task.CompletedTask;
129+
}
130+
catch (Exception ex)
122131
{
123-
await (PostCommitInsertAsync()).ConfigureAwait(false);
132+
return Task.FromException<object>(ex);
124133
}
125134
}
126135
}

src/NHibernate/Async/Action/EntityInsertAction.cs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,23 +89,32 @@ public override async Task ExecuteAsync()
8989
}
9090
}
9191

92-
protected override async Task AfterTransactionCompletionProcessImplAsync(bool success)
92+
protected override Task AfterTransactionCompletionProcessImplAsync(bool success)
9393
{
94-
//Make 100% certain that this is called before any subsequent ScheduledUpdate.afterTransactionCompletion()!!
95-
IEntityPersister persister = Persister;
96-
if (success && IsCachePutEnabled(persister))
94+
try
9795
{
98-
CacheKey ck = Session.GenerateCacheKey(Id, persister.IdentifierType, persister.RootEntityName);
99-
bool put = persister.Cache.AfterInsert(ck, cacheEntry, version);
96+
//Make 100% certain that this is called before any subsequent ScheduledUpdate.afterTransactionCompletion()!!
97+
IEntityPersister persister = Persister;
98+
if (success && IsCachePutEnabled(persister))
99+
{
100+
CacheKey ck = Session.GenerateCacheKey(Id, persister.IdentifierType, persister.RootEntityName);
101+
bool put = persister.Cache.AfterInsert(ck, cacheEntry, version);
102+
if (put && Session.Factory.Statistics.IsStatisticsEnabled)
103+
{
104+
Session.Factory.StatisticsImplementor.SecondLevelCachePut(Persister.Cache.RegionName);
105+
}
106+
}
100107

101-
if (put && Session.Factory.Statistics.IsStatisticsEnabled)
108+
if (success)
102109
{
103-
Session.Factory.StatisticsImplementor.SecondLevelCachePut(Persister.Cache.RegionName);
110+
return PostCommitInsertAsync();
104111
}
112+
113+
return Task.CompletedTask;
105114
}
106-
if (success)
115+
catch (Exception ex)
107116
{
108-
await (PostCommitInsertAsync()).ConfigureAwait(false);
117+
return Task.FromException<object>(ex);
109118
}
110119
}
111120

src/NHibernate/Async/Action/EntityUpdateAction.cs

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -118,30 +118,38 @@ public override async Task ExecuteAsync()
118118
}
119119
}
120120

121-
protected override async Task AfterTransactionCompletionProcessImplAsync(bool success)
121+
protected override Task AfterTransactionCompletionProcessImplAsync(bool success)
122122
{
123-
IEntityPersister persister = Persister;
124-
if (persister.HasCache)
123+
try
125124
{
126-
CacheKey ck = Session.GenerateCacheKey(Id, persister.IdentifierType, persister.RootEntityName);
127-
128-
if (success && cacheEntry != null)
125+
IEntityPersister persister = Persister;
126+
if (persister.HasCache)
129127
{
130-
bool put = persister.Cache.AfterUpdate(ck, cacheEntry, nextVersion, slock);
131-
132-
if (put && Session.Factory.Statistics.IsStatisticsEnabled)
128+
CacheKey ck = Session.GenerateCacheKey(Id, persister.IdentifierType, persister.RootEntityName);
129+
if (success && cacheEntry != null)
133130
{
134-
Session.Factory.StatisticsImplementor.SecondLevelCachePut(Persister.Cache.RegionName);
131+
bool put = persister.Cache.AfterUpdate(ck, cacheEntry, nextVersion, slock);
132+
if (put && Session.Factory.Statistics.IsStatisticsEnabled)
133+
{
134+
Session.Factory.StatisticsImplementor.SecondLevelCachePut(Persister.Cache.RegionName);
135+
}
136+
}
137+
else
138+
{
139+
persister.Cache.Release(ck, slock);
135140
}
136141
}
137-
else
142+
143+
if (success)
138144
{
139-
persister.Cache.Release(ck, slock);
145+
return PostCommitUpdateAsync();
140146
}
147+
148+
return Task.CompletedTask;
141149
}
142-
if (success)
150+
catch (Exception ex)
143151
{
144-
await (PostCommitUpdateAsync()).ConfigureAwait(false);
152+
return Task.FromException<object>(ex);
145153
}
146154
}
147155

src/NHibernate/Async/AdoNet/OracleDataClientBatchingBatcher.cs

Lines changed: 53 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -25,67 +25,74 @@ namespace NHibernate.AdoNet
2525
public partial class OracleDataClientBatchingBatcher : AbstractBatcher
2626
{
2727

28-
public override async Task AddToBatchAsync(IExpectation expectation)
28+
public override Task AddToBatchAsync(IExpectation expectation)
2929
{
30-
bool firstOnBatch = true;
31-
_totalExpectedRowsAffected += expectation.ExpectedRowCount;
32-
string lineWithParameters = null;
33-
var sqlStatementLogger = Factory.Settings.SqlStatementLogger;
34-
if (sqlStatementLogger.IsDebugEnabled || Log.IsDebugEnabled)
30+
try
3531
{
36-
lineWithParameters = sqlStatementLogger.GetCommandLineWithParameters(CurrentCommand);
37-
var formatStyle = sqlStatementLogger.DetermineActualStyle(FormatStyle.Basic);
38-
lineWithParameters = formatStyle.Formatter.Format(lineWithParameters);
39-
_currentBatchCommandsLog.Append("command ")
40-
.Append(_countOfCommands)
41-
.Append(":")
42-
.AppendLine(lineWithParameters);
43-
}
44-
if (Log.IsDebugEnabled)
45-
{
46-
Log.Debug("Adding to batch:" + lineWithParameters);
47-
}
32+
bool firstOnBatch = true;
33+
_totalExpectedRowsAffected += expectation.ExpectedRowCount;
34+
string lineWithParameters = null;
35+
var sqlStatementLogger = Factory.Settings.SqlStatementLogger;
36+
if (sqlStatementLogger.IsDebugEnabled || Log.IsDebugEnabled)
37+
{
38+
lineWithParameters = sqlStatementLogger.GetCommandLineWithParameters(CurrentCommand);
39+
var formatStyle = sqlStatementLogger.DetermineActualStyle(FormatStyle.Basic);
40+
lineWithParameters = formatStyle.Formatter.Format(lineWithParameters);
41+
_currentBatchCommandsLog.Append("command ").Append(_countOfCommands).Append(":").AppendLine(lineWithParameters);
42+
}
4843

49-
if (_currentBatch == null)
50-
{
51-
// use first command as the batching command
52-
_currentBatch = CurrentCommand;
53-
_parameterValueListHashTable = new Dictionary<string, List<object>>();
54-
//oracle does not allow array containing all null values
55-
// so this Dictionary is keeping track if all values are null or not
56-
_parameterIsAllNullsHashTable = new Dictionary<string, bool>();
57-
}
58-
else
59-
{
60-
firstOnBatch = false;
61-
}
44+
if (Log.IsDebugEnabled)
45+
{
46+
Log.Debug("Adding to batch:" + lineWithParameters);
47+
}
6248

63-
foreach (DbParameter currentParameter in CurrentCommand.Parameters)
64-
{
65-
List<object> parameterValueList;
66-
if (firstOnBatch)
49+
if (_currentBatch == null)
6750
{
68-
parameterValueList = new List<object>();
69-
_parameterValueListHashTable.Add(currentParameter.ParameterName, parameterValueList);
70-
_parameterIsAllNullsHashTable.Add(currentParameter.ParameterName, true);
51+
// use first command as the batching command
52+
_currentBatch = CurrentCommand;
53+
_parameterValueListHashTable = new Dictionary<string, List<object>>();
54+
//oracle does not allow array containing all null values
55+
// so this Dictionary is keeping track if all values are null or not
56+
_parameterIsAllNullsHashTable = new Dictionary<string, bool>();
7157
}
7258
else
7359
{
74-
parameterValueList = _parameterValueListHashTable[currentParameter.ParameterName];
60+
firstOnBatch = false;
7561
}
7662

77-
if (currentParameter.Value != DBNull.Value)
63+
foreach (DbParameter currentParameter in CurrentCommand.Parameters)
7864
{
79-
_parameterIsAllNullsHashTable[currentParameter.ParameterName] = false;
65+
List<object> parameterValueList;
66+
if (firstOnBatch)
67+
{
68+
parameterValueList = new List<object>();
69+
_parameterValueListHashTable.Add(currentParameter.ParameterName, parameterValueList);
70+
_parameterIsAllNullsHashTable.Add(currentParameter.ParameterName, true);
71+
}
72+
else
73+
{
74+
parameterValueList = _parameterValueListHashTable[currentParameter.ParameterName];
75+
}
76+
77+
if (currentParameter.Value != DBNull.Value)
78+
{
79+
_parameterIsAllNullsHashTable[currentParameter.ParameterName] = false;
80+
}
81+
82+
parameterValueList.Add(currentParameter.Value);
8083
}
81-
parameterValueList.Add(currentParameter.Value);
82-
}
8384

84-
_countOfCommands++;
85+
_countOfCommands++;
86+
if (_countOfCommands >= _batchSize)
87+
{
88+
return ExecuteBatchWithTimingAsync(_currentBatch);
89+
}
8590

86-
if (_countOfCommands >= _batchSize)
91+
return Task.CompletedTask;
92+
}
93+
catch (Exception ex)
8794
{
88-
await (ExecuteBatchWithTimingAsync(_currentBatch)).ConfigureAwait(false);
95+
return Task.FromException<object>(ex);
8996
}
9097
}
9198

src/NHibernate/Async/AdoNet/SqlClientBatchingBatcher.cs

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,39 @@ namespace NHibernate.AdoNet
2121
public partial class SqlClientBatchingBatcher : AbstractBatcher
2222
{
2323

24-
public override async Task AddToBatchAsync(IExpectation expectation)
24+
public override Task AddToBatchAsync(IExpectation expectation)
2525
{
26-
_totalExpectedRowsAffected += expectation.ExpectedRowCount;
27-
var batchUpdate = CurrentCommand;
28-
Driver.AdjustCommand(batchUpdate);
29-
string lineWithParameters = null;
30-
var sqlStatementLogger = Factory.Settings.SqlStatementLogger;
31-
if (sqlStatementLogger.IsDebugEnabled || Log.IsDebugEnabled)
32-
{
33-
lineWithParameters = sqlStatementLogger.GetCommandLineWithParameters(batchUpdate);
34-
var formatStyle = sqlStatementLogger.DetermineActualStyle(FormatStyle.Basic);
35-
lineWithParameters = formatStyle.Formatter.Format(lineWithParameters);
36-
_currentBatchCommandsLog.Append("command ")
37-
.Append(_currentBatch.CountOfCommands)
38-
.Append(":")
39-
.AppendLine(lineWithParameters);
40-
}
41-
if (Log.IsDebugEnabled)
26+
try
4227
{
43-
Log.Debug("Adding to batch:" + lineWithParameters);
44-
}
45-
_currentBatch.Append((System.Data.SqlClient.SqlCommand) batchUpdate);
28+
_totalExpectedRowsAffected += expectation.ExpectedRowCount;
29+
var batchUpdate = CurrentCommand;
30+
Driver.AdjustCommand(batchUpdate);
31+
string lineWithParameters = null;
32+
var sqlStatementLogger = Factory.Settings.SqlStatementLogger;
33+
if (sqlStatementLogger.IsDebugEnabled || Log.IsDebugEnabled)
34+
{
35+
lineWithParameters = sqlStatementLogger.GetCommandLineWithParameters(batchUpdate);
36+
var formatStyle = sqlStatementLogger.DetermineActualStyle(FormatStyle.Basic);
37+
lineWithParameters = formatStyle.Formatter.Format(lineWithParameters);
38+
_currentBatchCommandsLog.Append("command ").Append(_currentBatch.CountOfCommands).Append(":").AppendLine(lineWithParameters);
39+
}
4640

47-
if (_currentBatch.CountOfCommands >= _batchSize)
41+
if (Log.IsDebugEnabled)
42+
{
43+
Log.Debug("Adding to batch:" + lineWithParameters);
44+
}
45+
46+
_currentBatch.Append((System.Data.SqlClient.SqlCommand)batchUpdate);
47+
if (_currentBatch.CountOfCommands >= _batchSize)
48+
{
49+
return ExecuteBatchWithTimingAsync(batchUpdate);
50+
}
51+
52+
return Task.CompletedTask;
53+
}
54+
catch (Exception ex)
4855
{
49-
await (ExecuteBatchWithTimingAsync(batchUpdate)).ConfigureAwait(false);
56+
return Task.FromException<object>(ex);
5057
}
5158
}
5259

0 commit comments

Comments
 (0)