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 "Shannon, Bryan" <BS...@Tribune.com> on 2008/07/11 00:34:37 UTC

RE: Ibatis caching Empty ResultSet

Can someone please confirm whether or not iBatis used to cache the empty
resultset in previous versions?

We have a similar situation to Serge, in his slightly older thread, in
which our code relied on iBatis not returning the null result for the
second SELECT. (ie NOT caching an empty result)

Upon upgrading from 2.0.9B to the latest version of iBatis, we
discovered that our code which used to assume that the db query would be
re-run the second time (after the insert, similar to Serge) and find the
newly inserted value...

I understand that it DOES make sense to cache the empty results, but did
this logic change?  (I'm fully prepared to look at the code diffs
myself, but if someone could give me a head start, it'd be great!)

If it is the case that we have to flush the cache with the INSERT of
each new value, then it seems in these situations we'd only have about
item in our cache, rendering it less useful. 

Any help would be greatly appreciated! ;-)
-Bryan


-----Original Message-----
From: Serge Sozonoff [mailto:serge@sozonoff.com] 
Sent: Sunday, February 10, 2008 3:25 AM
To: user-java@ibatis.apache.org
Subject: Re: Ibatis caching Empty ResultSet

Hi Nathan and Jeff,

> The real question is why are you not clearing the cache on the insert 
> statement?
I don't see why I would clear the cache for an insert statement. As far
as I am concerned an inserted record shouldn't already be in the cache
before its been inserted.

> caches are generally agnostic about the content of the cache.
Agreed, the cache can be agnostic about its content but then the real
question is why is iBatis inserting an empty result set into the cache
in the first place.
>  
> This would solve your issue and ensure that your cache is always in a 
> "clean" state.  I know you claim that this "makes no sense" but it 
> does :) As long as you are issues more then one select between inserts

> which is normally the case.
Yes I know that will fix the problem but its totally stupid to flush the
entire cache upon insert of a new record.

Thanks,
Serge

RE: Ibatis caching Empty ResultSet

Posted by "Shannon, Bryan" <BS...@Tribune.com>.
 
Thanks, Larry.

That might be all we need to work around what we've done.  That's a
great help, thanks!
I'll dig through version control myself.

We've also noticed a very Sybase-specific (but unrelated) problem that
can be worked around, and I'll be sure to add it to the wiki. (Since I
noticed there was at least ONE other sybase user out there!)

Thanks again!
- Bryan



-----Original Message-----
From: Larry Meadors [mailto:larry.meadors@gmail.com] 
Sent: Thursday, July 10, 2008 10:43 PM
To: user-java@ibatis.apache.org
Subject: Re: Ibatis caching Empty ResultSet

Yes, that behavior did change, but I'm not positive when...it's been a
while.

Larry


On Thu, Jul 10, 2008 at 4:34 PM, Shannon, Bryan <BS...@tribune.com>
wrote:
> Can someone please confirm whether or not iBatis used to cache the 
> empty resultset in previous versions?
>
> We have a similar situation to Serge, in his slightly older thread, in

> which our code relied on iBatis not returning the null result for the 
> second SELECT. (ie NOT caching an empty result)
>
> Upon upgrading from 2.0.9B to the latest version of iBatis, we 
> discovered that our code which used to assume that the db query would 
> be re-run the second time (after the insert, similar to Serge) and 
> find the newly inserted value...
>
> I understand that it DOES make sense to cache the empty results, but 
> did this logic change?  (I'm fully prepared to look at the code diffs 
> myself, but if someone could give me a head start, it'd be great!)
>
> If it is the case that we have to flush the cache with the INSERT of 
> each new value, then it seems in these situations we'd only have about

> item in our cache, rendering it less useful.
>
> Any help would be greatly appreciated! ;-) -Bryan
>
>
> -----Original Message-----
> From: Serge Sozonoff [mailto:serge@sozonoff.com]
> Sent: Sunday, February 10, 2008 3:25 AM
> To: user-java@ibatis.apache.org
> Subject: Re: Ibatis caching Empty ResultSet
>
> Hi Nathan and Jeff,
>
>> The real question is why are you not clearing the cache on the insert
>> statement?
> I don't see why I would clear the cache for an insert statement. As
far
> as I am concerned an inserted record shouldn't already be in the cache
> before its been inserted.
>
>> caches are generally agnostic about the content of the cache.
> Agreed, the cache can be agnostic about its content but then the real
> question is why is iBatis inserting an empty result set into the cache
> in the first place.
>>
>> This would solve your issue and ensure that your cache is always in a
>> "clean" state.  I know you claim that this "makes no sense" but it
>> does :) As long as you are issues more then one select between
inserts
>
>> which is normally the case.
> Yes I know that will fix the problem but its totally stupid to flush
the
> entire cache upon insert of a new record.
>
> Thanks,
> Serge
>

Re: Ibatis caching Empty ResultSet

Posted by Larry Meadors <la...@gmail.com>.
Yes, that behavior did change, but I'm not positive when...it's been a while.

Larry


On Thu, Jul 10, 2008 at 4:34 PM, Shannon, Bryan <BS...@tribune.com> wrote:
> Can someone please confirm whether or not iBatis used to cache the empty
> resultset in previous versions?
>
> We have a similar situation to Serge, in his slightly older thread, in
> which our code relied on iBatis not returning the null result for the
> second SELECT. (ie NOT caching an empty result)
>
> Upon upgrading from 2.0.9B to the latest version of iBatis, we
> discovered that our code which used to assume that the db query would be
> re-run the second time (after the insert, similar to Serge) and find the
> newly inserted value...
>
> I understand that it DOES make sense to cache the empty results, but did
> this logic change?  (I'm fully prepared to look at the code diffs
> myself, but if someone could give me a head start, it'd be great!)
>
> If it is the case that we have to flush the cache with the INSERT of
> each new value, then it seems in these situations we'd only have about
> item in our cache, rendering it less useful.
>
> Any help would be greatly appreciated! ;-)
> -Bryan
>
>
> -----Original Message-----
> From: Serge Sozonoff [mailto:serge@sozonoff.com]
> Sent: Sunday, February 10, 2008 3:25 AM
> To: user-java@ibatis.apache.org
> Subject: Re: Ibatis caching Empty ResultSet
>
> Hi Nathan and Jeff,
>
>> The real question is why are you not clearing the cache on the insert
>> statement?
> I don't see why I would clear the cache for an insert statement. As far
> as I am concerned an inserted record shouldn't already be in the cache
> before its been inserted.
>
>> caches are generally agnostic about the content of the cache.
> Agreed, the cache can be agnostic about its content but then the real
> question is why is iBatis inserting an empty result set into the cache
> in the first place.
>>
>> This would solve your issue and ensure that your cache is always in a
>> "clean" state.  I know you claim that this "makes no sense" but it
>> does :) As long as you are issues more then one select between inserts
>
>> which is normally the case.
> Yes I know that will fix the problem but its totally stupid to flush the
> entire cache upon insert of a new record.
>
> Thanks,
> Serge
>