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 Stéphane Hanser <s....@omegames.com> on 2007/06/12 09:49:57 UTC
Caching queryForMap statements
Hi all,
When I profiled my web application, I figured that I was not able to cache
queries that return a Map as result. However it is the part I really do need
to optimize in order to speed up the application. Can you tell me if it is
possible or if I take it the wrong way?
Thanks in advance,
S. Hanser
In my Dao Class :
public Map getAntecedentsForAptitude(int id) {
Map map =
getSqlMapClientTemplate().queryForMap("Aptitude.getAntecedentsForAptitude",
new Integer(id), "aptitude", "niveau");
return map;
}
In my xml file :
<resultMap id="AptitudeMap.map" class="java.util.HashMap">
<result property="aptitude" column="id_aptitude_necessaire"
select="Aptitude.getOne"/>
<result property="niveau" column="niveau"/>
</resultMap>
<cacheModel id="AptitudeMap.cache" type="LRU">
<flushInterval hours="1"/>
<flushOnExecute statement="Aptitude.insertOne"/>
<flushOnExecute statement="Aptitude.updateOne"/>
<flushOnExecute statement="Aptitude.deleteOne"/>
<flushOnExecute statement="Aptidude.insertBonus"/>
<flushOnExecute statement="Aptitude.deleteBonus"/>
<property name="size" value="200" />
</cacheModel>
<select id="Aptitude.getAntecedentsForAptitude"
resultMap="AptitudeMap.map" cacheModel="AptitudeMap.cache" >
SELECT id_aptitude_necessaire, niveau
FROM antecedents_aptitudes
WHERE id_aptitude_voulue = #value#
</select>
RE: Caching queryForMap statements
Posted by Stéphane Hanser <s....@omegames.com>.
Sorry I don't grab iBATIS from svn but from the maven repository. You wrote
that it is the list that is cached, I trust you. To me it seemed that it did
send the requests but I didn't check my sql logs. Maybe it is the Map
construction that took so much time. I fixed it in a dirty way, as it
concerns only one statement I put the Map as a class attribute for now.
Stéphane.
-----Message d'origine-----
De : larry.meadors@gmail.com [mailto:larry.meadors@gmail.com] De la part de
Larry Meadors
Envoyé : mardi 12 juin 2007 15:43
À : user-java@ibatis.apache.org
Objet : Re: Caching queryForMap statements
What happens is the List that creates the Map is cached, but not the Map
itself.
If you check out the source from svn, replace the two files attached,
and then run the build - it might work. :-)
If it does work, let us know and I'll commit the changes for the next
release. If not...spend some time and make it work, then we'll commit
the changes for the next release.
Larry
On 6/12/07, Stéphane Hanser <s....@omegames.com> wrote:
>
>
>
>
> Hi all,
>
>
>
> When I profiled my web application, I figured that I was not able to cache
> queries that return a Map as result. However it is the part I really do
need
> to optimize in order to speed up the application. Can you tell me if it is
> possible or if I take it the wrong way?
>
>
>
> Thanks in advance,
>
>
>
> S. Hanser
>
>
>
> In my Dao Class :
>
>
>
> public Map getAntecedentsForAptitude(int id) {
>
> Map map =
>
getSqlMapClientTemplate().queryForMap("Aptitude.getAntecedentsForAptitude",
> new Integer(id), "aptitude", "niveau");
>
> return map;
>
> }
>
>
>
>
>
> In my xml file :
>
>
>
>
>
> <resultMap id="AptitudeMap.map" class="java.util.HashMap">
>
> <result property="aptitude" column="id_aptitude_necessaire"
> select="Aptitude.getOne"/>
>
> <result property="niveau" column="niveau"/>
>
> </resultMap>
>
>
>
>
>
> <cacheModel id="AptitudeMap.cache" type="LRU">
>
> <flushInterval hours="1"/>
>
> <flushOnExecute statement="Aptitude.insertOne"/>
>
> <flushOnExecute statement="Aptitude.updateOne"/>
>
> <flushOnExecute statement="Aptitude.deleteOne"/>
>
> <flushOnExecute statement="Aptidude.insertBonus"/>
>
> <flushOnExecute statement="Aptitude.deleteBonus"/>
>
> <property name="size" value="200" />
>
> </cacheModel>
>
>
>
>
>
> <select id="Aptitude.getAntecedentsForAptitude"
> resultMap="AptitudeMap.map" cacheModel="AptitudeMap.cache" >
>
> SELECT id_aptitude_necessaire, niveau
>
> FROM antecedents_aptitudes
>
> WHERE id_aptitude_voulue = #value#
>
> </select>
Re: Caching queryForMap statements
Posted by Larry Meadors <lm...@apache.org>.
What happens is the List that creates the Map is cached, but not the Map itself.
If you check out the source from svn, replace the two files attached,
and then run the build - it might work. :-)
If it does work, let us know and I'll commit the changes for the next
release. If not...spend some time and make it work, then we'll commit
the changes for the next release.
Larry
On 6/12/07, St�phane Hanser <s....@omegames.com> wrote:
>
>
>
>
> Hi all,
>
>
>
> When I profiled my web application, I figured that I was not able to cache
> queries that return a Map as result. However it is the part I really do need
> to optimize in order to speed up the application. Can you tell me if it is
> possible or if I take it the wrong way?
>
>
>
> Thanks in advance,
>
>
>
> S. Hanser
>
>
>
> In my Dao Class :
>
>
>
> public Map getAntecedentsForAptitude(int id) {
>
> Map map =
> getSqlMapClientTemplate().queryForMap("Aptitude.getAntecedentsForAptitude",
> new Integer(id), "aptitude", "niveau");
>
> return map;
>
> }
>
>
>
>
>
> In my xml file :
>
>
>
>
>
> <resultMap id="AptitudeMap.map" class="java.util.HashMap">
>
> <result property="aptitude" column="id_aptitude_necessaire"
> select="Aptitude.getOne"/>
>
> <result property="niveau" column="niveau"/>
>
> </resultMap>
>
>
>
>
>
> <cacheModel id="AptitudeMap.cache" type="LRU">
>
> <flushInterval hours="1"/>
>
> <flushOnExecute statement="Aptitude.insertOne"/>
>
> <flushOnExecute statement="Aptitude.updateOne"/>
>
> <flushOnExecute statement="Aptitude.deleteOne"/>
>
> <flushOnExecute statement="Aptidude.insertBonus"/>
>
> <flushOnExecute statement="Aptitude.deleteBonus"/>
>
> <property name="size" value="200" />
>
> </cacheModel>
>
>
>
>
>
> <select id="Aptitude.getAntecedentsForAptitude"
> resultMap="AptitudeMap.map" cacheModel="AptitudeMap.cache" >
>
> SELECT id_aptitude_necessaire, niveau
>
> FROM antecedents_aptitudes
>
> WHERE id_aptitude_voulue = #value#
>
> </select>