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 Michael Campbell <mi...@gmail.com> on 2005/09/26 04:23:22 UTC

caching... per "select"?

Setting up caching in iBATIS seems frighteningly easy, so I'm anxious
to try it.  Can anyone give me any idea of what GETS cached; it seems
to be per statement/select.  Can I assume that when some class is
listed in the parameterClass, that's part of the key? Is it the entire
thing, or just the attributes of the parameter that get used?

Lastly, how smart is this?  If I have a "getById" and
"getByDescription" and they both return the same object, that's an
object in each cache, since they're different selects/statements,
right?

Thanks!

--
I tend to view "truly flexible" by another term: "Make everything
equally hard". -- DHH

Re: caching... per "select"?

Posted by Larry Meadors <la...@gmail.com>.
Caching in iBATIS is based on the statement and the parameters passed to it.

So, if you execute "select * from Account where id = ?" three times,
with 3 different id parameters, you'll get 3 cache entries. If you
execute "select * from Account where name = ?" with the name of one of
those three, you will get a 4th cache entry, even if the row returned
is the same as one of the other, earlier select statements.

In iBATIS, there is currently no concept of "object identity", so if
you request account #5 three different ways, you'll get 3 different
objects.

Larry


On 9/25/05, Michael Campbell <mi...@gmail.com> wrote:
> Setting up caching in iBATIS seems frighteningly easy, so I'm anxious
> to try it.  Can anyone give me any idea of what GETS cached; it seems
> to be per statement/select.  Can I assume that when some class is
> listed in the parameterClass, that's part of the key? Is it the entire
> thing, or just the attributes of the parameter that get used?
>
> Lastly, how smart is this?  If I have a "getById" and
> "getByDescription" and they both return the same object, that's an
> object in each cache, since they're different selects/statements,
> right?
>
> Thanks!
>
> --
> I tend to view "truly flexible" by another term: "Make everything
> equally hard". -- DHH
>