Author: gbayon
Date: Sat Sep 15 05:43:08 2007
New Revision: 575913

URL: http://svn.apache.org/viewvc?rev=575913&view=rev
Log:
Fix IBATISNET-242 Cache error with QueryForObject<T>

Modified:
    
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheTest.cs
    
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Cache/CacheModel.cs
    
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/CachingStatement.cs

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheTest.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheTest.cs?rev=575913&r1=575912&r2=575913&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheTest.cs 
(original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheTest.cs 
Sat Sep 15 05:43:08 2007
@@ -50,6 +50,18 @@
                        Assert.IsNull(account);
                }
 
+        /// <summary>
+        /// Cache error with QueryForObject<T>
+        /// </summary>
+        [Test]
+        public void TestJIRA242()
+        {
+            Account account = 
sqlMap.QueryForObject<Account>("GetNoAccountWithCache", -99);
+            account = sqlMap.QueryForObject<Account>("GetNoAccountWithCache", 
-99);
+
+            Assert.IsNull(account);
+        }
+
            /// <summary>
                /// Test Cache query
                /// </summary>

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Cache/CacheModel.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Cache/CacheModel.cs?rev=575913&r1=575912&r2=575913&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Cache/CacheModel.cs 
(original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Cache/CacheModel.cs 
Sat Sep 15 05:43:08 2007
@@ -226,10 +226,6 @@
                        {
                                throw new ConfigurationException ("Error 
configuring controller named '"+_id+"'. Cause: " + e.Message, e);
                        }
-                       finally
-                       {
-
-                       }
                }
 
 

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/CachingStatement.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/CachingStatement.cs?rev=575913&r1=575912&r2=575913&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/CachingStatement.cs
 (original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/CachingStatement.cs
 Sat Sep 15 05:43:08 2007
@@ -369,7 +369,7 @@
                                // convert the marker object back into a null 
value 
                                obj = null; 
                        } 
-                       else if (obj == null) 
+                       else
                        {
                                obj = 
_mappedStatement.RunQueryForObject(request, session, parameterObject, 
resultObject);
                                this.Statement.CacheModel[cacheKey] = obj;
@@ -410,14 +410,14 @@
             CacheKey cacheKey = this.GetCacheKey(request);
             cacheKey.Update("ExecuteQueryForObject");
 
-            obj = (T)this.Statement.CacheModel[cacheKey];
+            //obj = (T)this.Statement.CacheModel[cacheKey];
             // check if this query has alreay been run 
-            if ((object)obj == CacheModel.NULL_OBJECT)
+            if (Statement.CacheModel[cacheKey] == CacheModel.NULL_OBJECT)
             {
                 // convert the marker object back into a null value 
                 obj = default(T);
             }
-            else if ((object)obj == null)
+            else //if ((object)obj == null)
             {
                 obj = (T)_mappedStatement.RunQueryForObject(request, session, 
parameterObject, resultObject);
                 this.Statement.CacheModel[cacheKey] = obj;


Reply via email to