If a <statement> has a "cacheModel" attribute set and 
cacheModelsEnabled="false" in SqlMap.config, an DataMapperException is thrown
-----------------------------------------------------------------------------------------------------------------------------------

         Key: IBATISNET-51
         URL: http://issues.apache.org/jira/browse/IBATISNET-51
     Project: iBatis for .NET
        Type: Bug
    Versions: DataMapper 1.2    
 Environment: [assembly: AssemblyVersion("1.1.458")]
DataMapper from 5/5/2005 SVN
    Reporter: Ron Grabowski
 Assigned to: Gilles Bayon 
    Priority: Minor


As of 5/5/2005, the version in SVN incorrectly throws an exception if a 
<statement> has a cacheModel attribute set to a valid <cacheModel>:

 <cacheModels>
  <cacheModel id="StateCache" type="LRU" implementation="MEMORY" >
   <flushInterval hours="12"/>                  
  </cacheModel>
  </cacheModels>
  <statements>
   <select id="GetOne" resultMap="StateResult" cacheModel="StateCache" 
parameterClass="int">

and the cacheModelsEnabled attribute is set to false in SqlMap.config:

 <settings>
  <setting useStatementNamespaces="true"/>
  <setting cacheModelsEnabled="false"/>
 </settings>

The following exception is thrown:

"
[DataMapperException: This SQL map does not contain an Cache named 
State.StateCache]
   IBatisNet.DataMapper.SqlMapper.GetCache(String name) in 
\IBatisNet.DataMapper\SqlMapper.cs:1229
   IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Initialize() in 
\IBatisNet.DataMapper\Configuration\DomSqlMapBuilder.cs:384
   IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument 
document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean 
isCallFromDao) in \IBatisNet.DataMapper\Configuration\DomSqlMapBuilder.cs:149

[ConfigurationException: 
- The error occurred while Set CacheModel to statement.
- statement :State.GetOne
- The error occurred in cacheModel : State.StateCache.  
- Check the .]
"

The exception is caused by this code starting on line 373 of 
DomSqlMapBuilder.cs:

 #region Attach CacheModel to statement
 foreach(DictionaryEntry entry in _configScope.SqlMapper.MappedStatements)

One way to prevent the exception would be to not go into the foreach loop if 
caching is disabled:

 #region Attach CacheModel to statement
 if (_configScope.IsCacheModelsEnabled)
 {
  foreach(DictionaryEntry entry in _configScope.SqlMapper.MappedStatements)

A few lines later in the file there is this code:

 _configScope.ErrorContext.MoreInfo = "statement 
:"+mappedStatement.Statement.Id;
 _configScope.ErrorContext.Resource = "cacheModel : " 
+mappedStatement.Statement.CacheModelName;

There is a space missing after "statement :". It should be:

 _configScope.ErrorContext.MoreInfo = "statement : 
"+mappedStatement.Statement.Id;
 _configScope.ErrorContext.Resource = "cacheModel : " 
+mappedStatement.Statement.CacheModelName;

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to