|
From: <fab...@us...> - 2010-08-05 11:06:53
|
Revision: 5112
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5112&view=rev
Author: fabiomaulo
Date: 2010-08-05 11:06:46 +0000 (Thu, 05 Aug 2010)
Log Message:
-----------
Fix NH-2273
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs
Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2010-08-05 03:06:22 UTC (rev 5111)
+++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2010-08-05 11:06:46 UTC (rev 5112)
@@ -16,13 +16,15 @@
private int totalExpectedRowsAffected;
private SqlClientSqlCommandSet currentBatch;
private StringBuilder currentBatchCommandsLog;
+ private readonly int defaultTimeout;
public SqlClientBatchingBatcher(ConnectionManager connectionManager, IInterceptor interceptor)
: base(connectionManager, interceptor)
{
batchSize = Factory.Settings.AdoBatchSize;
- currentBatch = new SqlClientSqlCommandSet();
- SetCommandTimeout();
+ defaultTimeout = PropertiesHelper.GetInt32(Cfg.Environment.CommandTimeout, Cfg.Environment.Properties, -1);
+
+ currentBatch = CreateConfiguredBatch();
//we always create this, because we need to deal with a scenario in which
//the user change the logging configuration at runtime. Trying to put this
//behind an if(log.IsDebugEnabled) will cause a null reference exception
@@ -30,26 +32,6 @@
currentBatchCommandsLog = new StringBuilder().AppendLine("Batch commands:");
}
- private void SetCommandTimeout()
- {
- int timeout = PropertiesHelper.GetInt32(Cfg.Environment.CommandTimeout, Cfg.Environment.Properties, -1);
-
- if (timeout > 0)
- {
- try
- {
- currentBatch.CommandTimeout = timeout;
- }
- catch (Exception e)
- {
- if (log.IsWarnEnabled)
- {
- log.Warn(e.ToString());
- }
- }
- }
- }
-
public override int BatchSize
{
get { return batchSize; }
@@ -107,7 +89,28 @@
currentBatch.Dispose();
totalExpectedRowsAffected = 0;
- currentBatch = new SqlClientSqlCommandSet();
+ currentBatch = CreateConfiguredBatch();
}
+
+ private SqlClientSqlCommandSet CreateConfiguredBatch()
+ {
+ var result = new SqlClientSqlCommandSet();
+ if (defaultTimeout > 0)
+ {
+ try
+ {
+ result.CommandTimeout = defaultTimeout;
+ }
+ catch (Exception e)
+ {
+ if (log.IsWarnEnabled)
+ {
+ log.Warn(e.ToString());
+ }
+ }
+ }
+
+ return result;
+ }
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|