From: <aye...@us...> - 2009-05-13 05:29:28
|
Revision: 4284 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4284&view=rev Author: ayenderahien Date: 2009-05-13 05:29:16 +0000 (Wed, 13 May 2009) Log Message: ----------- only do the log preparation if either logger wants it Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-12 15:29:32 UTC (rev 4283) +++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-13 05:29:16 UTC (rev 4284) @@ -32,19 +32,23 @@ { totalExpectedRowsAffected += expectation.ExpectedRowCount; IDbCommand batchUpdate = CurrentCommand; - string lineWithParameters = Factory.Settings.SqlStatementLogger.GetCommandLineWithParameters(batchUpdate); - currentBatchCommandsLog.Append("Batch command: ").AppendLine(lineWithParameters); - if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) + + if (log.IsDebugEnabled || Factory.Settings.SqlStatementLogger.IsDebugEnabled) + { + string lineWithParameters = Factory.Settings.SqlStatementLogger.GetCommandLineWithParameters(batchUpdate); + currentBatchCommandsLog.Append("Batch command: ").AppendLine(lineWithParameters); + if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) + { + Factory.Settings.SqlStatementLogger.LogCommand("Adding to batch:", batchUpdate, FormatStyle.Basic); + } + else if (log.IsDebugEnabled) + { + log.Debug("Adding to batch:" + lineWithParameters); + } + currentBatch.Append((System.Data.SqlClient.SqlCommand) batchUpdate); + } + if (currentBatch.CountOfCommands >= batchSize) { - Factory.Settings.SqlStatementLogger.LogCommand("Adding to batch:", batchUpdate, FormatStyle.Basic); - } - else if (log.IsDebugEnabled) - { - log.Debug("Adding to batch:" + lineWithParameters); - } - currentBatch.Append((System.Data.SqlClient.SqlCommand) batchUpdate); - if (currentBatch.CountOfCommands >= batchSize) - { DoExecuteBatch(batchUpdate); } } @@ -54,12 +58,15 @@ log.Debug("Executing batch"); CheckReaders(); Prepare(currentBatch.BatchCommand); - if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) - Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString()); - else if (log.IsDebugEnabled) - log.Debug(currentBatchCommandsLog.ToString()); - currentBatchCommandsLog = new StringBuilder(); - int rowsAffected = currentBatch.ExecuteNonQuery(); + if (log.IsDebugEnabled || Factory.Settings.SqlStatementLogger.IsDebugEnabled) + { + if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) + Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString()); + else if (log.IsDebugEnabled) + log.Debug(currentBatchCommandsLog.ToString()); + currentBatchCommandsLog = new StringBuilder(); + } + int rowsAffected = currentBatch.ExecuteNonQuery(); Expectations.VerifyOutcomeBatched(totalExpectedRowsAffected, rowsAffected); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2009-05-13 06:36:50
|
Revision: 4287 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4287&view=rev Author: ayenderahien Date: 2009-05-13 06:36:41 +0000 (Wed, 13 May 2009) Log Message: ----------- fixing whitespace issues Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-13 05:58:35 UTC (rev 4286) +++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-13 06:36:41 UTC (rev 4287) @@ -33,22 +33,22 @@ totalExpectedRowsAffected += expectation.ExpectedRowCount; IDbCommand batchUpdate = CurrentCommand; - if (log.IsDebugEnabled || Factory.Settings.SqlStatementLogger.IsDebugEnabled) - { - string lineWithParameters = Factory.Settings.SqlStatementLogger.GetCommandLineWithParameters(batchUpdate); - currentBatchCommandsLog.Append("Batch command: ").AppendLine(lineWithParameters); - if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) - { - Factory.Settings.SqlStatementLogger.LogCommand("Adding to batch:", batchUpdate, FormatStyle.Basic); - } - else if (log.IsDebugEnabled) - { - log.Debug("Adding to batch:" + lineWithParameters); - } - currentBatch.Append((System.Data.SqlClient.SqlCommand) batchUpdate); - } - if (currentBatch.CountOfCommands >= batchSize) + if (log.IsDebugEnabled || Factory.Settings.SqlStatementLogger.IsDebugEnabled) { + string lineWithParameters = Factory.Settings.SqlStatementLogger.GetCommandLineWithParameters(batchUpdate); + currentBatchCommandsLog.Append("Batch command: ").AppendLine(lineWithParameters); + if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) + { + Factory.Settings.SqlStatementLogger.LogCommand("Adding to batch:", batchUpdate, FormatStyle.Basic); + } + else if (log.IsDebugEnabled) + { + log.Debug("Adding to batch:" + lineWithParameters); + } + currentBatch.Append((System.Data.SqlClient.SqlCommand)batchUpdate); + } + if (currentBatch.CountOfCommands >= batchSize) + { DoExecuteBatch(batchUpdate); } } @@ -58,15 +58,15 @@ log.Debug("Executing batch"); CheckReaders(); Prepare(currentBatch.BatchCommand); - if (log.IsDebugEnabled || Factory.Settings.SqlStatementLogger.IsDebugEnabled) - { - if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) - Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString()); - else if (log.IsDebugEnabled) - log.Debug(currentBatchCommandsLog.ToString()); - currentBatchCommandsLog = new StringBuilder(); - } - int rowsAffected = currentBatch.ExecuteNonQuery(); + if (log.IsDebugEnabled || Factory.Settings.SqlStatementLogger.IsDebugEnabled) + { + if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) + Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString()); + else if (log.IsDebugEnabled) + log.Debug(currentBatchCommandsLog.ToString()); + currentBatchCommandsLog = new StringBuilder(); + } + int rowsAffected = currentBatch.ExecuteNonQuery(); Expectations.VerifyOutcomeBatched(totalExpectedRowsAffected, rowsAffected); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-13 15:38:04
|
Revision: 4289 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4289&view=rev Author: fabiomaulo Date: 2009-05-13 15:37:55 +0000 (Wed, 13 May 2009) Log Message: ----------- REVERT of SqlClientBatchingBatcher changes after r4279 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-13 09:17:42 UTC (rev 4288) +++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-13 15:37:55 UTC (rev 4289) @@ -19,7 +19,10 @@ { batchSize = Factory.Settings.AdoBatchSize; currentBatch = new SqlClientSqlCommandSet(); - currentBatchCommandsLog = new StringBuilder(); + if (log.IsDebugEnabled) + { + currentBatchCommandsLog = new StringBuilder(); + } } public override int BatchSize @@ -32,21 +35,24 @@ { totalExpectedRowsAffected += expectation.ExpectedRowCount; IDbCommand batchUpdate = CurrentCommand; - - if (log.IsDebugEnabled || Factory.Settings.SqlStatementLogger.IsDebugEnabled) + if (log.IsDebugEnabled) { string lineWithParameters = Factory.Settings.SqlStatementLogger.GetCommandLineWithParameters(batchUpdate); - currentBatchCommandsLog.Append("Batch command: ").AppendLine(lineWithParameters); if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) { Factory.Settings.SqlStatementLogger.LogCommand("Adding to batch:", batchUpdate, FormatStyle.Basic); } - else if (log.IsDebugEnabled) + else { log.Debug("Adding to batch:" + lineWithParameters); } - currentBatch.Append((System.Data.SqlClient.SqlCommand)batchUpdate); + currentBatchCommandsLog.Append("Batch command: ").AppendLine(lineWithParameters); } + else + { + Factory.Settings.SqlStatementLogger.LogCommand(batchUpdate, FormatStyle.Basic); + } + currentBatch.Append((System.Data.SqlClient.SqlCommand)batchUpdate); if (currentBatch.CountOfCommands >= batchSize) { DoExecuteBatch(batchUpdate); @@ -58,11 +64,11 @@ log.Debug("Executing batch"); CheckReaders(); Prepare(currentBatch.BatchCommand); - if (log.IsDebugEnabled || Factory.Settings.SqlStatementLogger.IsDebugEnabled) + if (log.IsDebugEnabled) { if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString()); - else if (log.IsDebugEnabled) + else log.Debug(currentBatchCommandsLog.ToString()); currentBatchCommandsLog = new StringBuilder(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2009-05-13 16:35:42
|
Revision: 4291 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4291&view=rev Author: ayenderahien Date: 2009-05-13 16:35:33 +0000 (Wed, 13 May 2009) Log Message: ----------- fixing issue with batcher only really batching when log is enabled Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-13 16:08:36 UTC (rev 4290) +++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-13 16:35:33 UTC (rev 4291) @@ -19,10 +19,7 @@ { batchSize = Factory.Settings.AdoBatchSize; currentBatch = new SqlClientSqlCommandSet(); - if (log.IsDebugEnabled) - { - currentBatchCommandsLog = new StringBuilder(); - } + currentBatchCommandsLog = new StringBuilder(); } public override int BatchSize @@ -35,23 +32,20 @@ { totalExpectedRowsAffected += expectation.ExpectedRowCount; IDbCommand batchUpdate = CurrentCommand; - if (log.IsDebugEnabled) + + if (log.IsDebugEnabled || Factory.Settings.SqlStatementLogger.IsDebugEnabled) { string lineWithParameters = Factory.Settings.SqlStatementLogger.GetCommandLineWithParameters(batchUpdate); + currentBatchCommandsLog.Append("Batch command: ").AppendLine(lineWithParameters); if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) { Factory.Settings.SqlStatementLogger.LogCommand("Adding to batch:", batchUpdate, FormatStyle.Basic); } - else + else if (log.IsDebugEnabled) { log.Debug("Adding to batch:" + lineWithParameters); } - currentBatchCommandsLog.Append("Batch command: ").AppendLine(lineWithParameters); } - else - { - Factory.Settings.SqlStatementLogger.LogCommand(batchUpdate, FormatStyle.Basic); - } currentBatch.Append((System.Data.SqlClient.SqlCommand)batchUpdate); if (currentBatch.CountOfCommands >= batchSize) { @@ -64,11 +58,11 @@ log.Debug("Executing batch"); CheckReaders(); Prepare(currentBatch.BatchCommand); - if (log.IsDebugEnabled) + if (log.IsDebugEnabled || Factory.Settings.SqlStatementLogger.IsDebugEnabled) { if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString()); - else + else if (log.IsDebugEnabled) log.Debug(currentBatchCommandsLog.ToString()); currentBatchCommandsLog = new StringBuilder(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2009-05-15 07:46:41
|
Revision: 4314 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4314&view=rev Author: ayenderahien Date: 2009-05-15 07:46:31 +0000 (Fri, 15 May 2009) Log Message: ----------- Fixing NRE when use dynamically change logging configuration Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-15 07:44:35 UTC (rev 4313) +++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-15 07:46:31 UTC (rev 4314) @@ -19,10 +19,11 @@ { batchSize = Factory.Settings.AdoBatchSize; currentBatch = new SqlClientSqlCommandSet(); - if (log.IsDebugEnabled) - { - currentBatchCommandsLog = new StringBuilder(); - } + //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 + //at that point. + currentBatchCommandsLog = new StringBuilder(); } public override int BatchSize This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |