[ 
http://issues.apache.org/jira/browse/IBATIS-182?page=comments#action_12318681 ] 

Ron Grabowski commented on IBATIS-182:
--------------------------------------

I don't think the putting cacheModels in the sqlMapConfig file is a good idea. 
I think the sqlMapConfig file should try to remain as small as possible.

I've made a similiar request for IBatisNet: 
http://issues.apache.org/jira/browse/IBATISNET-100 

In that issue, I proposed allowing a sqlMap file to contain only a caheModels 
node and/or a resultMaps node. A statements node would be optional.

 <!-- CacheModels.xml - Proposed syntax for IBATISNET-100 -->
 <sqlMap namespace="CacheModels">
  <cacheModels>
   <cacheModel id="UserCache" implementation="MEMORY">
    <property name="Type" value="Strong" />
    <flushInterval hours="2" />
    <flushOnExecute statement="User.Insert" />
    <flushOnExecute statement="User.Update" />
    <flushOnExecute statement="User.Delete" />
   </cacheModel>
  </cacheModels>
 </sqlMap>

I've also moved all of my resultMap nodes into their own ResultMaps.xml sqlMap 
file. 

My sqlMaps node in my sqlMapConfig file is as follows:

 <sqlMaps>
  <sqlMap resource="SqlMaps\CacheModels.xml" />
  <sqlMap resource="SqlMaps\ResultMaps.xml" />
  <sqlMap resource="SqlMaps\${DATABASE}\State.xml" />
  <sqlMap resource="SqlMaps\${DATABASE}\Region.xml" />
  <sqlMap resource="SqlMaps\${DATABASE}\User.xml" />
 </sqlMaps>

This is what my State.xml might look like:

 <sqlMap namespace="State">
  <statements>
   <select id="GetMany" resultMap="ResultMaps.StateResult" 
cacheModel="CacheModels.StateCache">
    SNIP
   </select>
  </statements>
</sqlMap>

The cacheModels are not attached to <statements> until all the statement nodes 
have been processed.

My other sqlMap files are very small and only contain code relating to the 
specified database.

Is this similiar to what your were thinking? I haven't commited this to 
IBatisNet yet. Can anything think of why this might be a BadIdea?

> Add global cache declaration
> ----------------------------
>
>          Key: IBATIS-182
>          URL: http://issues.apache.org/jira/browse/IBATIS-182
>      Project: iBatis for Java
>         Type: New Feature
>   Components: SQL Maps
>     Versions: 2.2.0, 2.2.5
>  Environment: All
>     Reporter: agharta

>
> Can i suggest a new feature??
> I suggest a global cache declaration, available for many sqlmap files.
> Example:
> Now,  into a sqlMap file:
> <cacheModel id="cache" readOnly="true" serialize="true" type="LRU">
>         <flushOnExecute statement="Author.insertAuthor"/>
>         <flushOnExecute statement="Author.updateAuthorById"/>
>         <flushOnExecute statement="Author.deleteAuthorById"/>
>         <property name="size" value="100000"/>
>         <flushInterval hours="24"/>
> </cacheModel>  
> Ok? This cache is valid only into this sqlmap file.
> So, following Spring's idea, if i have many sqlmap files and i want to extend 
> the same cache declaration....
> //into sqlMapConfig file or another dedicated file
> <cacheMap namespace="GlobalCache"> //new definition
>     <cacheModel id="cache" readOnly="true" serialize="true" type="LRU">
>         <flushOnExecute statement="insert*"/>
>         <flushOnExecute statement="update*"/>
>         <flushOnExecute statement="delete*"/>
>         <property name="size" value="100000"/>
>         <flushInterval hours="24"/>
>     </cacheModel>  
> </cacheMap>
> So, the sqlMap call the global cache model with the  
> useStatementNamespaces="true" setted into sqlmapconfig file (therefore many 
> global cache are availables)
> <statement id="getAuthorById" parameterClass="java.lang.Integer"
>         resultMap="get-author-result" cacheModel="GlobalCache.cache" >
>         <include refid="select"/>
>         WHERE ID = #value#
>  </statement>
> With this feature we'll save a lot of redundant code.
> I suggest a cache definition also into insert/update/delete statements, to 
> allow the internal or "global" cache selection.
> Is it possible??
> Thanks a lot for reply!
> Regards,
>                       Agharta

-- 
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