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 Neverov Dm <ne...@nkmk.ru> on 2006/04/21 02:17:53 UTC
Cache
Hi, I have question on cache.
There is statement:
<statement id="searchNorm" parameterClass="java.util.HashMap" resultMap="norm.NormWithValues" cacheModel="normCache">
select t.lname,
t.sname,
t.id,
t.active
from sp_name t
where t.pid = #pid#
<dynamic>
<isNotNull property="normId" prepend="and">
t.id = #normId#
</isNotNull>
</dynamic>
order by t.sname
</statement>
CacheModel is:
<cacheModel id="normCache" type="LRU" readOnly="true">
<flushOnExecute statement="norm.insertNorm"/>
<flushOnExecute statement="norm.updateNorm"/>
<flushOnExecute statement="norm.deleteNorm"/>
<property name="size" value="1000"/>
</cacheModel>
When I execute
public List getNormsAndNormatives(){
List result = new ArrayList();
result = normDao.getNormList(Norm.NORM_PID); //[1]
result.addAll(normDao.getNormList(Norm.NORMATIVS_PID));//[2]
return result;
}
at first time all is right, at [1] I get 3 item in list with pid =
Norm.NORM_PID and at [2] 2 items with pid = Norm.NORMATIVS_PID.
But then I invoke it second time, I get 5 items in a result at [1]
with pid = Norm.NORM_PID and pid = Norm.NORMATIVS_PID, and also get 2
items at [2] with pid = Norm.NORMATIVS_PID.
Is it because caching in iBATIS does not use object identity? I also
try to use OSCache with the same result. Is there any solution for
this problem?
--
Thanks.
mailto:neverov_dg@nkmk.ru
Re: Cache
Posted by Larry Meadors <lm...@apache.org>.
After you get the List, do you modify it in any way?
Because you are tell iBATIS that it is read-only, you are gettign a
shared instance of the list. Any changes you make to it will be
reflected in later calls that return the same (shared) list.
Larry
On 4/24/06, Neverov Dm <ne...@nkmk.ru> wrote:
> Nobody have such problem?
>
>
> > Hi, I have question on cache.
>
> > There is statement:
>
> > <statement id="searchNorm" parameterClass="java.util.HashMap"
> > resultMap="norm.NormWithValues" cacheModel="normCache">
> > select t.lname,
> > t.sname,
> > t.id,
> > t.active
> > from sp_name t
> > where t.pid = #pid#
> > <dynamic>
> > <isNotNull property="normId" prepend="and">
> > t.id = #normId#
> > </isNotNull>
> > </dynamic>
> > order by t.sname
> > </statement>
>
> > CacheModel is:
>
> > <cacheModel id="normCache" type="LRU" readOnly="true">
> > <flushOnExecute statement="norm.insertNorm"/>
> > <flushOnExecute statement="norm.updateNorm"/>
> > <flushOnExecute statement="norm.deleteNorm"/>
> > <property name="size" value="1000"/>
> > </cacheModel>
>
>
> > When I execute
>
> > public List getNormsAndNormatives(){
> > List result = new ArrayList();
> > result = normDao.getNormList(Norm.NORM_PID); //[1]
> > result.addAll(normDao.getNormList(Norm.NORMATIVS_PID));//[2]
> > return result;
> > }
>
> > at first time all is right, at [1] I get 3 item in list with pid =
> > Norm.NORM_PID and at [2] 2 items with pid = Norm.NORMATIVS_PID.
>
> > But then I invoke it second time, I get 5 items in a result at [1]
> > with pid = Norm.NORM_PID and pid = Norm.NORMATIVS_PID, and also get 2
> > items at [2] with pid = Norm.NORMATIVS_PID.
>
> > Is it because caching in iBATIS does not use object identity? I also
> > try to use OSCache with the same result. Is there any solution for
> > this problem?
>
>
> ---------------------------------
> --
> Neverov mailto:neverov_dg@nkmk.ru
>
>
>
>
>
Re: Cache
Posted by Neverov Dm <ne...@nkmk.ru>.
Nobody have such problem?
> Hi, I have question on cache.
> There is statement:
> <statement id="searchNorm" parameterClass="java.util.HashMap"
> resultMap="norm.NormWithValues" cacheModel="normCache">
> select t.lname,
> t.sname,
> t.id,
> t.active
> from sp_name t
> where t.pid = #pid#
> <dynamic>
> <isNotNull property="normId" prepend="and">
> t.id = #normId#
> </isNotNull>
> </dynamic>
> order by t.sname
> </statement>
> CacheModel is:
> <cacheModel id="normCache" type="LRU" readOnly="true">
> <flushOnExecute statement="norm.insertNorm"/>
> <flushOnExecute statement="norm.updateNorm"/>
> <flushOnExecute statement="norm.deleteNorm"/>
> <property name="size" value="1000"/>
> </cacheModel>
> When I execute
> public List getNormsAndNormatives(){
> List result = new ArrayList();
> result = normDao.getNormList(Norm.NORM_PID); //[1]
> result.addAll(normDao.getNormList(Norm.NORMATIVS_PID));//[2]
> return result;
> }
> at first time all is right, at [1] I get 3 item in list with pid =
> Norm.NORM_PID and at [2] 2 items with pid = Norm.NORMATIVS_PID.
> But then I invoke it second time, I get 5 items in a result at [1]
> with pid = Norm.NORM_PID and pid = Norm.NORMATIVS_PID, and also get 2
> items at [2] with pid = Norm.NORMATIVS_PID.
> Is it because caching in iBATIS does not use object identity? I also
> try to use OSCache with the same result. Is there any solution for
> this problem?
---------------------------------
--
Neverov mailto:neverov_dg@nkmk.ru