ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jean-Francois Poilpret" <jfpoilp...@hcm.vnn.vn>
Subject RE: cacheModel still hitting database
Date Tue, 22 Feb 2005 16:48:25 GMT
Hi James,

Did you try with another type of cache?
Although the SqlMaps documentation does not say anything about it, I had bad
experiences in the past with the WEAK reference types (outside of iBATIS)
and I did not check it again since that time (I was using JDK 1.3 then).
My concern was that all such references were EAGERLY garbage-collected (ie,
AS SOON AS there were no strong reference left to the object).

So you may run in the same kind of problem:
If you do not hold any strong reference to the objects got from the first
select execution, then it is possible that all your cached objects have been
garbage collected on the second select execution.

Try either to change to another model of cache (LRU for instance) or change
the reference-type to STRONG if you keep the MEMORY cache. I would not be
surprised if any of these changes solved your problem.

If I am right, then I am afraid you cannot do much to solve the problem if
you do want to keep the same cache settings. 
For information, which JDK are you running?

Hope this helps



-----Original Message-----
From: James, Steven [mailto:Steven.James@logicacmg.com] 
Sent: Tuesday, February 22, 2005 9:51 PM
To: ibatis-user-java@incubator.apache.org
Subject: RE: cacheModel still hitting database

Yes my settings are 


inmy sql.xml file cachemodel is set like this

 <cacheModel id="tnodes-cache" type="MEMORY">
	<flushInterval seconds= "360"/>
	<flushOnExecute statement="insertNode"/>
	<flushOnExecute statement="deleteNode"/>
	<flushOnExecute statement="deleteAllNodes"/>
	<flushOnExecute statement="updateNode"/>
	<property name="size"  value="1000"/>
	<property name="reference-type" value="WEAK" />

and finally select element is like this
<select id="getNodeTypeByName" parameterClass="java.lang.String"
resultMap="resultNode" cacheModel="tnodes-cache">
      	select * from T_NODES where NAME = #name#

This looks to me like a case of muppititus but i can't see it yet..

-----Original Message-----
From: Mark Bennett [mailto:mark.bennett@ncmail.net]
Sent: Tue 2/22/2005 1:44 PM
To: ibatis-user-java@incubator.apache.org; krisajenkins@yahoo.co.uk
Subject: RE: cacheModel still hitting database
Yup, that was it thanks.  Hey Steven, this may work for you too.


-----Original Message-----
From: Kris A. Jenkins [mailto:krisajenkins@yahoo.co.uk]
Sent: Monday, February 21, 2005 5:33 PM
To: ibatis-user-java@incubator.apache.org
Subject: Re: cacheModel still hitting database


In your sql-map-config.xml, look at the 'settings'
attribute.  Do you have 'cacheModelsEnabled="true"'


 --- Mark Bennett <mark.bennett@ncmail.net> wrote:
> I'm trying to get the cacheModel working, but it
> keeps hitting the database.
> This is just an example so please ignore the
> context.
> I'm using iBatis-2 and this setup returns the data
> properly.  I get no
> errors.  This is run through a web container and not
> a unit test so the
> cache should persist.  The query object is an
> Integer so it should hash the
> same each time.  However, whenever I cange the data
> in the databse, the
> change shows up on the page.  Any advice?  Thanks.
> Mark
>   <cacheModel id="drugScreenCache" type="LRU"
> readOnly="true"
> serialize="false">
>     <flushInterval hours="12"/>
>     <property name="cache-size" value="500"/>
>   </cacheModel>
>   <resultMap id="drugScreenListResult"
> class="drugScreen">
>     <result property="id" column="ACTID"/>
>     <result property="testDate" column="TESTDATE"/>
>   </resultMap>
>   <select id="getDrugScreenListByJuvenile"
>   		resultMap="drugScreenListResult"
>   		cacheModel="drugScreenCache">
>     SELECT *
>     FROM drugscreen
>     WHERE rsrcid = #value#
>   </select>

ALL-NEW Yahoo! Messenger - all new features - even more fun!

This e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be copied,
disclosed to, retained or used by, any other party. If you are not an
intended recipient then please promptly delete this e-mail and any
attachment and all copies and inform the sender. Thank you.

View raw message