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:
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.
Any ideas? What the heck?!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2004-12-01
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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"