ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: Caching by pre-loading
Date Thu, 04 Jan 2007 23:56:42 GMT
iBATIS caches by SQL statement - your two statements are different, so there
is a cache miss.  This also demonstrates a fundamental truth about iBATIS -
iBATIS doesn't know about object identity.  So iBATIS would have no way of
looking through the first set of cached results to see if an object from the
second statement already is available.

You could accomplish what you want by loading all the employees into some
cache that you manage - and then selecting individual employees from your
cache.  Maybe your cache could just be a simple HashMap keyed by employee
id?

Jeff Butler





On 1/4/07, James Johnson <johnson.james2@gmail.com> wrote:
>
> How does iBatis determine whether results are to be pulled from the cache
> or to be queried from the database? For instance, if I have a query like
> such: "select * from employee" and then follow-up with a second query of
> "select * from employee where id=1", the second query appears to hit the
> database instead of finding the employee object in the cache with id=1. Is
> there way to have iBatis get the object from the cached results of the 1st
> query? Both queries are in the same sqlMap xml have the same result map.
>
> I'm trying to pre-load all employees at web application start so that the
> first user request (for a given set of employees) doesn't take a hit on
> response time. Most user requests are for 1-10 employees.
>
> Thanks in advance.
>

Mime
View raw message