Author: gbayon
Date: Sat Sep 15 05:03:39 2007
New Revision: 575907
URL: http://svn.apache.org/viewvc?rev=575907&view=rev
Log:
Fix IBATISNET-241 GroupByStrategy must use "pre-instantiated" result objects
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/GroupByTest.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/GroupByStrategy.cs
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/GroupByTest.cs
URL:
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/GroupByTest.cs?rev=575907&r1=575906&r2=575907&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/GroupByTest.cs
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/GroupByTest.cs
Sat Sep 15 05:03:39 2007
@@ -5,6 +5,7 @@
#endif
using IBatisNet.DataMapper.Test.Domain;
using NUnit.Framework;
+using Category=IBatisNet.DataMapper.Test.Domain.Petshop.Category;
namespace IBatisNet.DataMapper.Test.NUnit.SqlMapTests
{
@@ -149,6 +150,23 @@
Assert.AreEqual(4, cat.GenericProducts.Count);
Domain.Petshop.Product product = cat.GenericProducts[0];
+ Assert.AreEqual(2, product.GenericItems.Count);
+ }
+
+ [Test]
+ public void TestJira241()
+ {
+ Category myCategory = new Category();
+
+ sqlMap.QueryForObject<Category>("GetFishGeneric", null,
myCategory);
+ Assert.IsNotNull(myCategory);
+
+ Assert.AreEqual("FISH", myCategory.Id);
+ Assert.AreEqual("Fish", myCategory.Name);
+ Assert.IsNotNull(myCategory.GenericProducts, "Expected product
list.");
+ Assert.AreEqual(4, myCategory.GenericProducts.Count);
+
+ Domain.Petshop.Product product = myCategory.GenericProducts[0];
Assert.AreEqual(2, product.GenericItems.Count);
}
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/GroupByStrategy.cs
URL:
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/GroupByStrategy.cs?rev=575907&r1=575906&r2=575907&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/GroupByStrategy.cs
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/ResultStrategy/GroupByStrategy.cs
Sat Sep 15 05:03:39 2007
@@ -79,8 +79,12 @@
{
// Unique key is NOT known, so create a new result object and
process additional results.
- // temp ?, we don't support constructor tag with groupBy
attribute
- outObject = resultMap.CreateInstanceOfResult(null);
+ // Fix IBATISNET-241
+ if (outObject == null)
+ {
+ // temp ?, we don't support constructor tag with groupBy
attribute
+ outObject = resultMap.CreateInstanceOfResult(null);
+ }
for (int index = 0; index < resultMap.Properties.Count;
index++)
{