Author: gbayon
Date: Mon Jul 11 11:05:17 2005
New Revision: 210170

URL: http://svn.apache.org/viewcvs?rev=210170&view=rev
Log:
- Fixed issue with Hashtable type resultMap and nullvalue

Modified:
    
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Order.xml
    
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ParameterMapTest.cs
    
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs
    
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Order.xml
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Order.xml?rev=210170&r1=210169&r2=210170&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Order.xml 
(original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Order.xml 
Mon Jul 11 11:05:17 2005
@@ -62,6 +62,10 @@
                        <result property="PostalCode" 
column="Order_PostalCode"/>
                </resultMap>
                
+               <resultMap id="order-hash" class="Hashtable">
+                       <result property="Date"       column="Order_Date" 
nullValue="01/01/0001 00:00:00"/>
+               </resultMap>
+               
                <resultMap id="order-with-types-result" class="Order">
                        <result property="Id"         column="Order_ID"         
        dbType="Int"/><!-- Int for SqlClient, Obdc; Integer for Oledb -->
                        <result property="Date"       column="Order_Date"       
        dbType="DateTime "/>
@@ -185,6 +189,12 @@
                                        parameterClass="Int"
                                        resultMap="lite-order-result-by-name" >
                        select * from Orders where Order_ID = #value#
+               </statement>
+               
+               <statement id="GetOrderByHashTable"
+                                       parameterClass="Int"
+                                       resultMap="order-hash" >
+                       select Order_Date from Orders where Order_ID = #value#
                </statement>
                
                <statement id="GetOrderLiteByColumnIndex"

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ParameterMapTest.cs
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ParameterMapTest.cs?rev=210170&r1=210169&r2=210170&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ParameterMapTest.cs
 (original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/ParameterMapTest.cs
 Mon Jul 11 11:05:17 2005
@@ -137,6 +137,36 @@
                }
 
                /// <summary>
+               /// Test null replacement in ParameterMap/Hahstable property
+               /// for System.DateTime.MinValue
+               /// </summary>
+               [Test] 
+               public void TestNullValueReplacementForDateTimeWithHashtable()
+               {
+                       Account account = NewAccount6();
+
+                       sqlMap.Insert("InsertAccountViaParameterMap", account);
+
+                       Order order = new Order();
+                       order.Id = 99;
+                       order.CardExpiry = "09/11";
+                       order.Account = account;
+                       order.CardNumber = "154564656";
+                       order.CardType = "Visa";
+                       order.City = "Lyon";
+                       order.Date = DateTime.MinValue; //<-- null replacement
+                       order.PostalCode = "69004";
+                       order.Province = "Rhone";
+                       order.Street = "rue Durand";
+ 
+                       sqlMap.Insert("InsertOrderViaParameterMap", order);
+
+                       Hashtable orderTest = (Hashtable) 
sqlMap.QueryForObject("GetOrderByHashTable", 99);
+
+                       Assert.AreEqual(orderTest["Date"], DateTime.MinValue);
+               }
+
+               /// <summary>
                /// Test null replacement in ParameterMap property
                /// for Guid
                /// </summary>

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs?rev=210170&r1=210169&r2=210170&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs
 (original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs
 Mon Jul 11 11:05:17 2005
@@ -319,7 +319,14 @@
                        {
                                if (this.HasNullValue) 
                                {
-                                       value = 
_typeHandler.ValueOf(_propertyInfo.PropertyType, _nullValue);
+                                       if (_propertyInfo!=null)
+                                       {
+                                               value = 
_typeHandler.ValueOf(_propertyInfo.PropertyType, _nullValue);
+                                       }
+                                       else
+                                       {
+                                               value = 
_typeHandler.ValueOf(null, _nullValue);
+                                       }
                                }
                                else
                                {

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs?rev=210170&r1=210169&r2=210170&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs 
(original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs 
Mon Jul 11 11:05:17 2005
@@ -928,11 +928,11 @@
                                // We have a 'normal' ResultMap
 
                                #region Not a select statement
-                               if (mapping.TypeHandler == null) // Find the 
TypeHandler
+                               if (mapping.TypeHandler == null || 
mapping.TypeHandler is UnknownTypeHandler) // Find the TypeHandler
                                {
                                        lock(mapping) 
                                        {
-                                               if (mapping.TypeHandler == null)
+                                               if (mapping.TypeHandler == null 
|| mapping.TypeHandler is UnknownTypeHandler)
                                                {
                                                        int columnIndex = 0;
                                                        if (mapping.ColumnIndex 
== ResultProperty.UNKNOWN_COLUMN_INDEX) 


Reply via email to