Author: gbayon
Date: Sat Jul 23 06:48:20 2005
New Revision: 224465
URL: http://svn.apache.org/viewcvs?rev=224465&view=rev
Log:
- Fixed IBATISNET-97
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/MappedStatement.cs
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheTest.cs
URL:
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheTest.cs?rev=224465&r1=224464&r2=224465&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 Jul 23 06:48:20 2005
@@ -156,7 +156,9 @@
cache["testKey"] = null;
object returnedObject = cache["testKey"];
- Assert.IsNull(returnedObject);
+ Assert.AreEqual(CacheModel.NULL_OBJECT, returnedObject);
+
Assert.AreEqual(HashCodeProvider.GetIdentityHashCode(CacheModel.NULL_OBJECT),
HashCodeProvider.GetIdentityHashCode(returnedObject));
+ Assert.AreEqual(1, cache.HitRatio);
}
Modified:
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Cache/CacheModel.cs
URL:
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Cache/CacheModel.cs?rev=224465&r1=224464&r2=224465&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Cache/CacheModel.cs
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Cache/CacheModel.cs
Sat Jul 23 06:48:20 2005
@@ -53,7 +53,13 @@
[NonSerialized]
private static readonly ILog _logger = LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType );
-
+ /// <summary>
+ /// This is used to represent null objects that are returned
from the cache so
+ /// that they can be cached, too.
+ /// </summary>
+ [NonSerialized]
+ public readonly static object NULL_OBJECT = new Object();
+
/// <summary>
/// Constant to turn off periodic cache flushes
/// </summary>
@@ -272,6 +278,7 @@
}
set
{
+ if (null == value) value = NULL_OBJECT;
_controller[key] = value;
}
}
@@ -285,8 +292,7 @@
{
if (_requests!=0)
{
- return
- (double)_hits/(double)_requests;
+ return (double)_hits/(double)_requests;
}
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=224465&r1=224464&r2=224465&view=diff
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
Sat Jul 23 06:48:20 2005
@@ -35,6 +35,7 @@
using IBatisNet.Common.Logging;
using IBatisNet.Common.Utilities.Objects;
using IBatisNet.DataMapper.Commands;
+using IBatisNet.DataMapper.Configuration.Cache;
using IBatisNet.DataMapper.Configuration.ParameterMapping;
using IBatisNet.DataMapper.Configuration.ResultMapping;
using IBatisNet.DataMapper.Configuration.Statements;
@@ -419,7 +420,13 @@
}
obj = _statement.CacheModel[key];
- if (obj == null)
+ // check if this query has alreay been run
+ if (obj == CacheModel.NULL_OBJECT)
+ {
+ // convert the marker object back into
a null value
+ obj = null;
+ }
+ else if (obj == null)
{
obj = RunQueryForObject(request,
session, parameterObject, resultObject);
_statement.CacheModel[key] = obj;