@@ -164,29 +164,29 @@ protected override int DoUpdateRows(object id, IPersistentCollection collection,
164
164
IExpectation deleteExpectation = Expectations . AppropriateExpectation ( DeleteCheckStyle ) ;
165
165
bool useBatch = deleteExpectation . CanBeBatched ;
166
166
SqlCommandInfo sql = SqlDeleteRowString ;
167
- IDbCommand st = null ;
168
167
// update removed rows fks to null
169
- try
170
- {
171
- int i = 0 ;
172
- IEnumerable entries = collection . Entries ( this ) ;
168
+ int i = 0 ;
169
+ IEnumerable entries = collection . Entries ( this ) ;
173
170
174
- foreach ( object entry in entries )
171
+ foreach ( object entry in entries )
172
+ {
173
+ if ( collection . NeedsUpdating ( entry , i , ElementType ) )
175
174
{
176
- if ( collection . NeedsUpdating ( entry , i , ElementType ) )
175
+ IDbCommand st = null ;
176
+ // will still be issued when it used to be null
177
+ if ( useBatch )
177
178
{
178
- // will still be issued when it used to be null
179
- if ( useBatch )
180
- {
181
- st = session . Batcher . PrepareBatchCommand ( SqlDeleteRowString . CommandType , sql . Text ,
182
- SqlDeleteRowString . ParameterTypes ) ;
183
- }
184
- else
185
- {
186
- st = session . Batcher . PrepareCommand ( SqlDeleteRowString . CommandType , sql . Text ,
187
- SqlDeleteRowString . ParameterTypes ) ;
188
- }
179
+ st = session . Batcher . PrepareBatchCommand ( SqlDeleteRowString . CommandType , sql . Text ,
180
+ SqlDeleteRowString . ParameterTypes ) ;
181
+ }
182
+ else
183
+ {
184
+ st = session . Batcher . PrepareCommand ( SqlDeleteRowString . CommandType , sql . Text ,
185
+ SqlDeleteRowString . ParameterTypes ) ;
186
+ }
189
187
188
+ try
189
+ {
190
190
int loc = WriteKey ( st , id , offset , session ) ;
191
191
WriteElementToWhere ( st , collection . GetSnapshotElement ( entry , i ) , loc , session ) ;
192
192
if ( useBatch )
@@ -197,25 +197,25 @@ protected override int DoUpdateRows(object id, IPersistentCollection collection,
197
197
{
198
198
deleteExpectation . VerifyOutcomeNonBatched ( session . Batcher . ExecuteNonQuery ( st ) , st ) ;
199
199
}
200
- count ++ ;
201
200
}
202
- i ++ ;
203
- }
204
- }
205
- catch ( Exception e )
206
- {
207
- if ( useBatch )
208
- {
209
- session . Batcher . AbortBatch ( e ) ;
210
- }
211
- throw ;
212
- }
213
- finally
214
- {
215
- if ( ! useBatch && st != null )
216
- {
217
- session . Batcher . CloseCommand ( st , null ) ;
201
+ catch ( Exception e )
202
+ {
203
+ if ( useBatch )
204
+ {
205
+ session . Batcher . AbortBatch ( e ) ;
206
+ }
207
+ throw ;
208
+ }
209
+ finally
210
+ {
211
+ if ( ! useBatch && st != null )
212
+ {
213
+ session . Batcher . CloseCommand ( st , null ) ;
214
+ }
215
+ }
216
+ count ++ ;
218
217
}
218
+ i ++ ;
219
219
}
220
220
}
221
221
@@ -225,28 +225,28 @@ protected override int DoUpdateRows(object id, IPersistentCollection collection,
225
225
//bool callable = InsertCallable;
226
226
bool useBatch = insertExpectation . CanBeBatched ;
227
227
SqlCommandInfo sql = SqlInsertRowString ;
228
- IDbCommand st = null ;
229
228
230
229
// now update all changed or added rows fks
231
- try
230
+ int i = 0 ;
231
+ IEnumerable entries = collection . Entries ( this ) ;
232
+ foreach ( object entry in entries )
232
233
{
233
- int i = 0 ;
234
- IEnumerable entries = collection . Entries ( this ) ;
235
- foreach ( object entry in entries )
234
+ if ( collection . NeedsUpdating ( entry , i , ElementType ) )
236
235
{
237
- if ( collection . NeedsUpdating ( entry , i , ElementType ) )
236
+ IDbCommand st = null ;
237
+ if ( useBatch )
238
238
{
239
- if ( useBatch )
240
- {
241
- st = session . Batcher . PrepareBatchCommand ( SqlInsertRowString . CommandType , sql . Text ,
242
- SqlInsertRowString . ParameterTypes ) ;
243
- }
244
- else
245
- {
246
- st = session . Batcher . PrepareCommand ( SqlInsertRowString . CommandType , sql . Text ,
247
- SqlInsertRowString . ParameterTypes ) ;
248
- }
239
+ st = session . Batcher . PrepareBatchCommand ( SqlInsertRowString . CommandType , sql . Text ,
240
+ SqlInsertRowString . ParameterTypes ) ;
241
+ }
242
+ else
243
+ {
244
+ st = session . Batcher . PrepareCommand ( SqlInsertRowString . CommandType , sql . Text ,
245
+ SqlInsertRowString . ParameterTypes ) ;
246
+ }
249
247
248
+ try
249
+ {
250
250
//offset += insertExpectation.Prepare(st, Factory.ConnectionProvider.Driver);
251
251
int loc = WriteKey ( st , id , offset , session ) ;
252
252
if ( HasIndex && ! indexContainsFormula )
@@ -262,25 +262,25 @@ protected override int DoUpdateRows(object id, IPersistentCollection collection,
262
262
{
263
263
insertExpectation . VerifyOutcomeNonBatched ( session . Batcher . ExecuteNonQuery ( st ) , st ) ;
264
264
}
265
- count ++ ;
266
265
}
267
- i ++ ;
268
- }
269
- }
270
- catch ( Exception e )
271
- {
272
- if ( useBatch )
273
- {
274
- session . Batcher . AbortBatch ( e ) ;
275
- }
276
- throw ;
277
- }
278
- finally
279
- {
280
- if ( ! useBatch && st != null )
281
- {
282
- session . Batcher . CloseCommand ( st , null ) ;
266
+ catch ( Exception e )
267
+ {
268
+ if ( useBatch )
269
+ {
270
+ session . Batcher . AbortBatch ( e ) ;
271
+ }
272
+ throw ;
273
+ }
274
+ finally
275
+ {
276
+ if ( ! useBatch && st != null )
277
+ {
278
+ session . Batcher . CloseCommand ( st , null ) ;
279
+ }
280
+ }
281
+ count ++ ;
283
282
}
283
+ i ++ ;
284
284
}
285
285
}
286
286
return count ;
0 commit comments