ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sean Dillon <s...@dillonsoftware.com>
Subject caching, doesn't
Date Wed, 01 Dec 2004 18:22:21 GMT
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 <sean@dillonsoftware.com>
Dillon Software


Mime
View raw message