You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by gb...@apache.org on 2008/03/18 20:53:07 UTC

svn commit: r638539 - in /ibatis/trunk/cs/mapper: IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/ IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ IBatisNet.DataMapper/Configuration/ IBatisNet.DataMapper/Configuration/ResultMapping/

Author: gbayon
Date: Tue Mar 18 12:53:02 2008
New Revision: 638539

URL: http://svn.apache.org/viewvc?rev=638539&view=rev
Log:
Fix IBATISNET-260

Modified:
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConstructorTest.cs
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml?rev=638539&r1=638538&r2=638539&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml Tue Mar 18 12:53:02 2008
@@ -82,6 +82,20 @@
       <result property="Guid" column="Category_Guid" nullValue="00000000-0000-0000-0000-000000000000"/>
     </resultMap>
     
+   <resultMap id="account-constructor"  class="Account" >
+			<constructor>
+				<argument argumentName="identifiant"	column="Account_ID"/>
+				<argument argumentName="firstName"    column="Account_FirstName"/>
+				<argument argumentName="lastName"     column="Account_LastName"/>
+			</constructor>
+		</resultMap>
+
+    <resultMap id="account-extends-constructor"  class="Account"  extends="account-constructor">
+      <result property="EmailAddress" column="Account_Email" nullValue="no_email@provided.com"/>
+      <result property="BannerOption" column="Account_Banner_Option" dbType="Varchar" type="bool"/>
+      <result property="CartOption"	  column="Account_Cart_Option" typeHandler="HundredsBool"/>
+    </resultMap>
+    
 		<resultMap id="account-result-constructor"  class="Account" >
 			<constructor>
 				<argument argumentName="identifiant"	column="Account_ID"/>
@@ -163,6 +177,13 @@
     -->
   <statements>
 
+    <select id="JIRA260" parameterClass="Integer"
+      resultMap="account-extends-constructor">
+      select *
+      from Accounts
+      where Account_ID = #value#
+    </select>
+    
     <select id="JIRA206"
        resultMap="account-groupby">
       SELECT

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConstructorTest.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConstructorTest.cs?rev=638539&r1=638538&r2=638539&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConstructorTest.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ConstructorTest.cs Tue Mar 18 12:53:02 2008
@@ -54,6 +54,17 @@
 			AssertAccount1(account);
 		}
 
+        [Test]
+        [Category("JIRA")]
+        [Category("JIRA-260")]
+        public void TestExtendsConstructor()
+        {
+            Account account = sqlMap.QueryForObject("JIRA260", 1) as Account;
+            AssertAccount1(account);
+            Assert.IsTrue(account.BannerOption );
+            Assert.IsFalse(account.CartOption);
+        }
+
 #if dotnet2
         /// <summary>
         /// Test argument nullable constructor mapping

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs?rev=638539&r1=638538&r2=638539&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs Tue Mar 18 12:53:02 2008
@@ -1869,8 +1869,21 @@
                             resultMap.GroupByPropertyNames.Add(superMap.GroupByPropertyNames[i]);
                         }
                     }
+                    // Add constructor arguments 
+                    if (resultMap.Parameters.Count == 0)
+                    {
+                       for (int i = 0; i < superMap.Parameters.Count; i++)
+                       {
+                           resultMap.Parameters.Add(superMap.Parameters[i]);
+                       }
+                       if (resultMap.Parameters.Count>0)
+                       {
+                           resultMap.SetObjectFactory(_configScope);
+                       }
+                    }
 
-                    // Verify that that each groupBy element correspond to a class member
+
+				    // Verify that that each groupBy element correspond to a class member
                     // of one of result property
                     for (int i = 0; i < resultMap.GroupByPropertyNames.Count; i++)
                     {

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs?rev=638539&r1=638538&r2=638539&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs Tue Mar 18 12:53:02 2008
@@ -390,7 +390,22 @@
 			#endregion 
 		}
 
-		/// <summary>
+        /// <summary>
+        /// Sets the object factory.
+        /// </summary>
+        public void SetObjectFactory(ConfigurationScope configScope)
+        {
+            Type[] parametersType = new Type[_parameters.Count];
+            for (int i = 0; i < _parameters.Count; i++)
+            {
+                ArgumentProperty argumentMapping = (ArgumentProperty)_parameters[i];
+                parametersType[i] = argumentMapping.MemberType;
+            }
+            // Init the object factory
+            _objectFactory = configScope.SqlMapper.ObjectFactory.CreateFactory(_class, parametersType);
+        }
+
+	    /// <summary>
 		/// Finds the constructor that takes the parameters.
 		/// </summary>
 		/// <param name="type">The <see cref="System.Type"/> to find the constructor in.</param>