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:
Next, the cache model definition from a sqlmap called "Campaigns":
<cacheModel id="CampaignsCache" type="MEMORY" readOnly="false">
<property name="reference-type" value="STRONG"/>
AND NOW, here's the select statement that I would think WOULD be cached:
<select id="titles" resultClass="java.util.HashMap" cacheModel="CampaignsCache">
Titles.id as "id",
Titles.name as "name",
Titles.description as "description",
Titles.img as "img",
CampaignTitles.position as "position"
CampaignTitles.campaignId = #value#
and CampaignTitles.titleId = Titles.id
order by position
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.
Any ideas? What the heck?!
Oh, and I tried changing the cacheModel="CampaignsCache" in my select tag to cacheModel="Campaigns.CampaignsCache", thinking it might be a namespace issue. Interesting enough, both seem to NOT work equally. I would have expected one or the other would have generated an error at startup when the file is parsed.
Look in the docs about readOnly="false". I think that may prevent the caching behavior you are expecting.
Also, try using LRU instead of MEMORY. Maybe your results are getting garbage collected.
The same problem i had when i used Lru.
Even the case is getting worse if u use serialize option along with readOnly="false"
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.