emacarron / mybatis

Automatically exported from code.google.com/p/mybatis
0 stars 0 forks source link

Two select calls with the same query cause ResultHandler to silently return #139

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What version of the MyBatis are you using?

3.0.2

Please describe the problem.  Unit tests are best!

When a call to SqlSession.select( String, ResultHandler ) is made immediately 
after a call to SqlSession.selectList( String ) using the exact same SQL select 
statement, the ResultHandler silently returns without having had any results 
passed to it by Mybatis.

What is the expected output? What do you see instead?

It is expected that the ResultHandler would have had results passed to it, 
since the first call to SqlSession.selectList( String ) returns data and the 
select with ResultHandler uses the exact same query.

However, if the first call to SqlSession.selectList( String ) is commented out 
and the application is re-run, the ResultHandler's handleResult() method is 
then called by Mybatis and the expected query results are then seen.

Likewise, if the first call to SqlSession.selectList( String ) is uncommented 
again and a call to SqlSession.clearCache() is placed immediately after this 
call, then the ResultHandler's handleResult() method is then called by Mybatis 
and the expected results are then seen as well.

If the results from the first query are in the local cache, then I would expect 
them to be passed to the ResultHandler in the second select() with 
ResultHandler. And, of course, if the previous query's results are not in the 
cache, I would still expect the query results to be presented to the 
ResultHandler.

Please provide any additional information below.

This issue was discussed in mybatis-user here:

http://groups.google.com/group/mybatis-user/browse_thread/thread/e454178f39c3b79
6

There may be a previous version of this issue in the system, I happened to 
close the browser window for that issue accidentally and have no idea if the 
system saved it or not, very sorry if it did.

konbonwa @t gmail dot com

Original issue reported on code.google.com by konbo...@gmail.com on 13 Oct 2010 at 5:45

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
The attached patch fixes this bug by disabling the local cache if the result 
handler is anything other than DefaultResultHandler.

Original comment by patrick....@3pillarglobal.com on 18 Mar 2011 at 3:27

Attachments:

GoogleCodeExporter commented 9 years ago
It would be great if we could have the option (in 3.0.5) to disable the local 
cache completely. See also related issues / comments that suggest the same. 
Many thanks.

Original comment by montgolf...@gmail.com on 18 Mar 2011 at 4:06

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Issue 257 has been merged into this issue.

Original comment by nathan.m...@gmail.com on 25 May 2011 at 2:22

GoogleCodeExporter commented 9 years ago
see r3769 && r3770 

Original comment by eduardo.macarron on 27 May 2011 at 4:38