You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Sean Dillon <se...@dillonsoftware.com> on 2004/12/01 19:22:21 UTC

caching, doesn't

Ok, I'm stuck, and I have an uncomfortable feeling that the queries I
*thought* were cached are, in fact, not. Case in point: The following
query does NOT cache the results. First, a snippet from my sqlmap.xml
config file: 
 
<settings 
cacheModelsEnabled="true" 
enhancementEnabled="true" 
lazyLoadingEnabled="false" 
maxRequests="32" 
maxSessions="10" 
maxTransactions="5" 
useStatementNamespaces="true" /> 
 
Next, the cache model definition from a sqlmap called "Campaigns": 
 
<cacheModel id="CampaignsCache" type="MEMORY" readOnly="false"> 
   <flushInterval minutes="30"/> 
   <property name="reference-type" value="STRONG"/> 
</cacheModel> 
 
 
AND NOW, here's the select statement that I would think WOULD be
cached: 
 
<select id="titles" resultClass="java.util.HashMap"
cacheModel="CampaignsCache"> 
   select 
      Titles.id as "id", 
      Titles.name as "name", 
      Titles.description as "description", 
      Titles.img as "img", 
      CampaignTitles.position as "position" 
   from 
      CampaignTitles, Titles 
   where 
      CampaignTitles.campaignId = #value# 
      and CampaignTitles.titleId = Titles.id 
      order by position 
</select> 
 
This statement is being called with a single Integer parameter as
follows: 
 
// Get a list of titles for this campaign. Should be cached. 
List titles = getSqlMapExecutor().queryForList("Campaigns.titles", new
Integer(campaignId)); 
 
So, what am I missing here? If I execute my dao code such that it
returns a list, and then use sql*plus to perform a manual update in the
database, and then execute the dao again to retrieve the list, I'm
seeing the change... but I shouldn't, because it should have been cached
- it should NOT have gone to the database, so the change should NOT be
reflected in the returned list.

I've tried changing the cacheModel attribute of the select tag to both
CampaignsCache and Campaigns.CampaignsCache thinking it might be a
namespace issue - no luck.  I also tried providing a
parameterClass="int" in the select tag.  Again, no luck.
 
Any ideas? What the heck?! 

-- 
Sean Dillon <se...@dillonsoftware.com>
Dillon Software