From: <fab...@us...> - 2010-10-12 17:57:36
|
Revision: 5247 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5247&view=rev Author: fabiomaulo Date: 2010-10-12 17:57:29 +0000 (Tue, 12 Oct 2010) Log Message: ----------- Re-Fix NH-2020 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2020/Fixture.cs Modified: trunk/nhibernate/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs 2010-10-12 17:25:31 UTC (rev 5246) +++ trunk/nhibernate/src/NHibernate/AdoNet/OracleDataClientBatchingBatcher.cs 2010-10-12 17:57:29 UTC (rev 5247) @@ -1,10 +1,11 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Data; +using System.Data.Common; using System.Reflection; using System.Text; using NHibernate.AdoNet.Util; +using NHibernate.Exceptions; namespace NHibernate.AdoNet { @@ -126,7 +127,15 @@ // this value is not a part of the ADO.NET API. // It's and ODP implementation, so it is being set by reflection SetObjectParam(currentBatch, "ArrayBindCount", arraySize); - int rowsAffected = currentBatch.ExecuteNonQuery(); + int rowsAffected; + try + { + rowsAffected = currentBatch.ExecuteNonQuery(); + } + catch (DbException e) + { + throw ADOExceptionHelper.Convert(Factory.SQLExceptionConverter, e, "could not execute batch command."); + } Expectations.VerifyOutcomeBatched(totalExpectedRowsAffected, rowsAffected); Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2010-10-12 17:25:31 UTC (rev 5246) +++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2010-10-12 17:57:29 UTC (rev 5247) @@ -1,6 +1,8 @@ using System.Data; +using System.Data.Common; using System.Text; using NHibernate.AdoNet.Util; +using NHibernate.Exceptions; using NHibernate.Util; namespace NHibernate.AdoNet @@ -82,9 +84,17 @@ Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString()); currentBatchCommandsLog = new StringBuilder().AppendLine("Batch commands:"); } - - int rowsAffected = currentBatch.ExecuteNonQuery(); + int rowsAffected; + try + { + rowsAffected = currentBatch.ExecuteNonQuery(); + } + catch (DbException e) + { + throw ADOExceptionHelper.Convert(Factory.SQLExceptionConverter, e, "could not execute batch command."); + } + Expectations.VerifyOutcomeBatched(totalExpectedRowsAffected, rowsAffected); currentBatch.Dispose(); Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2020/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2020/Fixture.cs 2010-10-12 17:25:31 UTC (rev 5246) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2020/Fixture.cs 2010-10-12 17:57:29 UTC (rev 5247) @@ -1,10 +1,8 @@ -using System; - using NUnit.Framework; - using NHibernate.Dialect; using NHibernate.Exceptions; using NHibernate.Test.ExceptionsTest; +using SharpTestsEx; namespace NHibernate.Test.NHSpecificTest.NH2020 { @@ -13,7 +11,7 @@ { protected override void Configure(Cfg.Configuration configuration) { - configuration.SetProperty(Cfg.Environment.BatchSize, "1"); + configuration.SetProperty(Cfg.Environment.BatchSize, "10"); configuration.SetProperty( Cfg.Environment.SqlExceptionConverter, typeof (MSSQLExceptionConverterExample).AssemblyQualifiedName); @@ -58,17 +56,8 @@ using (ITransaction tx = s.BeginTransaction()) { var one = s.Load<One>(oneId); - - try - { - s.Delete(one); - tx.Commit(); - Assert.Fail("DELETE should have failed"); - } - catch (Exception ex) - { - Assert.IsInstanceOf<ConstraintViolationException>(ex); - } + s.Delete(one); + tx.Executing(transaction => transaction.Commit()).Throws<ConstraintViolationException>(); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |