From: <dav...@us...> - 2009-08-05 19:58:40
|
Revision: 4684 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4684&view=rev Author: davybrion Date: 2009-08-05 19:58:32 +0000 (Wed, 05 Aug 2009) Log Message: ----------- Fix NH-1913 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs trunk/nhibernate/src/NHibernate/AdoNet/SqlClientSqlCommandSet.cs Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-08-05 19:46:31 UTC (rev 4683) +++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-08-05 19:58:32 UTC (rev 4684) @@ -1,6 +1,7 @@ using System.Data; using System.Text; using NHibernate.AdoNet.Util; +using NHibernate.Util; namespace NHibernate.AdoNet { @@ -21,6 +22,7 @@ { batchSize = Factory.Settings.AdoBatchSize; currentBatch = new SqlClientSqlCommandSet(); + SetCommandTimeout(); //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 @@ -28,6 +30,26 @@ 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; } Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientSqlCommandSet.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientSqlCommandSet.cs 2009-08-05 19:46:31 UTC (rev 4683) +++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientSqlCommandSet.cs 2009-08-05 19:58:32 UTC (rev 4684) @@ -18,6 +18,7 @@ private object instance; private PropSetter<SqlConnection> connectionSetter; private PropSetter<SqlTransaction> transactionSetter; + private PropSetter<int> commandTimeoutSetter; private PropGetter<SqlConnection> connectionGetter; private SqlClientSqlCommandSet.PropGetter<System.Data.SqlClient.SqlCommand> commandGetter; private AppendCommand doAppend; @@ -41,6 +42,9 @@ transactionSetter = (PropSetter<SqlTransaction>) Delegate.CreateDelegate(typeof(PropSetter<SqlTransaction>), instance, "set_Transaction"); + commandTimeoutSetter = (PropSetter<int>) + Delegate.CreateDelegate(typeof(PropSetter<int>), + instance, "set_CommandTimeout"); connectionGetter = (PropGetter<SqlConnection>) Delegate.CreateDelegate(typeof(PropGetter<SqlConnection>), instance, "get_Connection"); @@ -130,6 +134,11 @@ set { transactionSetter(value); } } + public int CommandTimeout + { + set { commandTimeoutSetter(value); } + } + ///<summary> ///Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. ///</summary> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |