Author: gbayon
Date: Sat Nov  3 06:44:57 2007
New Revision: 591621

URL: http://svn.apache.org/viewvc?rev=591621&view=rev
Log:
Fix IBATISNET-245 Stored procedure parameter cache should be cleared when map 
is reset using ConfigureAndWatch.

Modified:
    ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/DBHelperParameterCache.cs
    
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
    
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatementFactory.cs
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/ISqlMapper.cs
    ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/DBHelperParameterCache.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/DBHelperParameterCache.cs?rev=591621&r1=591620&r2=591621&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/DBHelperParameterCache.cs 
(original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/DBHelperParameterCache.cs 
Sat Nov  3 06:44:57 2007
@@ -39,13 +39,12 @@
        /// </summary>
        public sealed class DBHelperParameterCache
        {
-               //Since this class provides only static methods, make the 
default constructor private to prevent 
-               //instances from being created.
-               private DBHelperParameterCache() {}
-
-               #region Private fields
-               private static Hashtable _paramCache = 
Hashtable.Synchronized(new Hashtable());
-               #endregion
+               private Hashtable _paramCache = Hashtable.Synchronized(new 
Hashtable());
+
+        /// <summary>
+        /// Initializes a new instance of the <see 
cref="DBHelperParameterCache"/> class.
+        /// </summary>
+        public DBHelperParameterCache() { }
 
                #region private methods
 
@@ -56,7 +55,7 @@
                /// <param name="spName">the name of the stored 
procedure</param>
                /// <param name="includeReturnValueParameter">whether or not to 
include their return value parameter</param>
                /// <returns></returns>
-               private static IDataParameter[] 
DiscoverSpParameterSet(IDalSession session, string spName, bool 
includeReturnValueParameter)
+               private IDataParameter[] DiscoverSpParameterSet(IDalSession 
session, string spName, bool includeReturnValueParameter)
                {
                        return InternalDiscoverSpParameterSet(
                 session,
@@ -72,7 +71,7 @@
                /// <param name="spName">Name of the stored procedure.</param>
         /// <param name="includeReturnValueParameter">if set to <c>true</c> 
[include return value parameter].</param>
         /// <returns>The stored procedure parameters.</returns>
-               private static IDataParameter[] 
InternalDiscoverSpParameterSet(IDalSession session, string spName, 
+               private IDataParameter[] 
InternalDiscoverSpParameterSet(IDalSession session, string spName, 
             bool includeReturnValueParameter)
                {
 #if !dotnet2
@@ -119,7 +118,7 @@
 #endif
                }
                
-               private static void DeriveParameters(IDbProvider provider, 
IDbCommand command)
+               private void DeriveParameters(IDbProvider provider, IDbCommand 
command)
                {
                        Type commandBuilderType;
 
@@ -151,7 +150,7 @@
                /// </summary>
                /// <param name="originalParameters"></param>
                /// <returns></returns>
-               private static IDataParameter[] 
CloneParameters(IDataParameter[] originalParameters)
+               private IDataParameter[] CloneParameters(IDataParameter[] 
originalParameters)
                {
                        IDataParameter[] clonedParameters = new 
IDataParameter[originalParameters.Length];
 
@@ -174,7 +173,7 @@
                /// <param name="connectionString">a valid connection string 
for an IDbConnection</param>
                /// <param name="commandText">the stored procedure name or SQL 
command</param>
                /// <param name="commandParameters">an array of IDataParameters 
to be cached</param>
-               public static void CacheParameterSet(string connectionString, 
string commandText, params IDataParameter[] commandParameters)
+               public void CacheParameterSet(string connectionString, string 
commandText, params IDataParameter[] commandParameters)
                {
                        string hashKey = connectionString + ":" + commandText;
 
@@ -182,11 +181,10 @@
                }
 
 
-               // FM Added
                /// <summary>
                /// Clear the parameter cache.
                /// </summary>
-               public static void Clear()
+               public void Clear()
                {
                        _paramCache.Clear();
                }
@@ -197,7 +195,7 @@
                /// <param name="connectionString">a valid connection string 
for an IDbConnection</param>
                /// <param name="commandText">the stored procedure name or SQL 
command</param>
                /// <returns>an array of IDataParameters</returns>
-               public static IDataParameter[] GetCachedParameterSet(string 
connectionString, string commandText)
+               public IDataParameter[] GetCachedParameterSet(string 
connectionString, string commandText)
                {
                        string hashKey = connectionString + ":" + commandText;
 
@@ -226,7 +224,7 @@
                /// <param name="session">a valid session</param>
                /// <param name="spName">the name of the stored 
procedure</param>
                /// <returns>an array of IDataParameters</returns>
-               public static IDataParameter[] GetSpParameterSet(IDalSession 
session, string spName)
+               public IDataParameter[] GetSpParameterSet(IDalSession session, 
string spName)
                {
                        return GetSpParameterSet(session, spName, false);
                }
@@ -241,7 +239,7 @@
                /// <param name="spName">the name of the stored 
procedure</param>
                /// <param name="includeReturnValueParameter">a bool value 
indicating whether the return value parameter should be included in the 
results</param>
                /// <returns>an array of IDataParameters</returns>
-               public static IDataParameter[] GetSpParameterSet(IDalSession 
session, 
+               public IDataParameter[] GetSpParameterSet(IDalSession session, 
                        string spName, bool includeReturnValueParameter)
                {
                        string hashKey = session.DataSource.ConnectionString + 
":" + spName + (includeReturnValueParameter ? ":include ReturnValue 
Parameter":"");

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=591621&r1=591620&r2=591621&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs 
(original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs 
Sat Nov  3 06:44:57 2007
@@ -365,24 +365,7 @@
             _paramParser = new InlineParameterMapParser();
             _deSerializerFactory = new DeSerializerFactory(_configScope);
                }
-
-               /// <summary>
-               /// Constructs a DomSqlMapBuilder 
-               /// with or without configuration document validation using the 
-               /// SqlMapConfig schema.
-               /// </summary>
-               /// <param name="validateSqlMapConfig">
-               /// Specify whether the configuration Xml document should be 
-               /// validated with the SqlMapConfig schema.
-               /// </param>
-        [Obsolete("Set the ValidateSqlMapConfig property before calling the 
Configure method.")]
-               public DomSqlMapBuilder(bool validateSqlMapConfig)
-               {
-                       _configScope = new ConfigurationScope();
-            _validateSqlMapConfig = validateSqlMapConfig;
-                       _deSerializerFactory = new 
DeSerializerFactory(_configScope);
-                       _paramParser = new InlineParameterMapParser();
-               }               
+       
                #endregion 
 
                #region Configure
@@ -492,7 +475,7 @@
                /// <returns>An ISqlMapper instance.</returns>
                public ISqlMapper ConfigureAndWatch( string resource, 
ConfigureHandler configureDelegate )
                {
-                       XmlDocument document;
+                       XmlDocument document = null;
                        if (resource.StartsWith("file://"))
                        {
                                document = Resources.GetUrlAsXmlDocument( 
resource.Remove(0, 7) );      

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatementFactory.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatementFactory.cs?rev=591621&r1=591620&r2=591621&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatementFactory.cs
 (original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatementFactory.cs
 Sat Nov  3 06:44:57 2007
@@ -168,7 +168,7 @@
                {
                        // pull the parameters for this stored procedure from 
the parameter cache 
                        // (or discover them & populate the cache)
-                       IDataParameter[] commandParameters = 
DBHelperParameterCache.GetSpParameterSet(session, _commandText);
+            IDataParameter[] commandParameters = 
session.SqlMapper.DBHelperParameterCache.GetSpParameterSet(session, 
_commandText);
 
             _preparedStatement.DbParameters = new 
IDbDataParameter[commandParameters.Length];
 

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/ISqlMapper.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/ISqlMapper.cs?rev=591621&r1=591620&r2=591621&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/ISqlMapper.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/ISqlMapper.cs Sat Nov  3 
06:44:57 2007
@@ -43,6 +43,7 @@
 using IBatisNet.DataMapper.MappedStatements;
 using IBatisNet.DataMapper.SessionStore;
 using IBatisNet.DataMapper.TypeHandlers;
+using IBatisNet.Common.Utilities;
 #endregion
 
 namespace IBatisNet.DataMapper
@@ -80,6 +81,12 @@
         ///  currently being used by the SqlMap.
         /// </summary>
         ISqlMapSession LocalSession { get; }
+
+        /// <summary>
+        /// Gets the DB helper parameter cache.
+        /// </summary>
+        /// <value>The DB helper parameter cache.</value>
+        DBHelperParameterCache DBHelperParameterCache { get; }
 
         /// <summary>
         /// Creates a new SqlMapSession that will be used to query the data 
source.

Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs?rev=591621&r1=591620&r2=591621&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/SqlMapper.cs Sat Nov  3 
06:44:57 2007
@@ -68,6 +68,7 @@
                //(CacheModel name, cache))
                private HybridDictionary _cacheMaps = new HybridDictionary();
                private TypeHandlerFactory _typeHandlerFactory = null; 
+        private DBHelperParameterCache _dbHelperParameterCache = null;
 
                private bool _cacheModelsEnabled = false;
                // An identifiant 
@@ -124,6 +125,15 @@
                        get { return (_sessionStore.LocalSession != null); }
                }
 
+        /// <summary>
+        /// Gets the DB helper parameter cache.
+        /// </summary>
+        /// <value>The DB helper parameter cache.</value>
+        public DBHelperParameterCache DBHelperParameterCache
+        {
+            get { return _dbHelperParameterCache; }
+        }
+
                /// <summary>
                /// Factory for DataExchange objects
                /// </summary>
@@ -180,6 +190,7 @@
             AccessorFactory accessorFactory) 
                {
             _typeHandlerFactory = new TypeHandlerFactory();
+            _dbHelperParameterCache = new DBHelperParameterCache();
             _objectFactory = objectFactory;
             _accessorFactory = accessorFactory;
 


Reply via email to