lioralon / mybatisnet

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

Read/write, nonserializable caching appears not to work #11

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Read/write, nonserializable caching appears not to work because consecutive 
calls from the same thread to a SELECT statement with such a cache model return 
different objects.

Inspecting the logs reveals that this is because each request gets a new cache 
key, even though the SQL is identical.

There is an archived email thread about this issue here: 
http://www.mail-archive.com/user-cs@ibatis.apache.org/msg02271.html In that 
thread, Gilles indicates that he checked in a test and it worked; however that 
test does not expose the issue because it does not use a read/write, 
nonserializable cache model.

Steps to reproduce:

1) Set up a SQL Map with a read/write, nonserializable cache model and a SELECT 
statement that uses it (example below)
2) Write a test that calls the statement twice in a row using one of the 
ISqlMapper QueryForXYZ() methods
3) Run the test with debug logging enabled. Examine the log and note that both 
statements result in cahce misses using different cache keys

SQL Map snippets:

<cacheModel id="rw-nonserializable-account-cache" implementation="FIFO" 
serialize="false" readOnly="false">
<flushInterval hours="24"/>
<flushOnExecute statement="UpdateAccountViaInlineParameters"/>
</cacheModel>
...
<select id="GetRWNSCachedAccountsViaResultMap"
resultMap="account-result"
cacheModel="rw-nonserializable-account-cache" 
extends="GetCachedAccountsViaResultMap">
</select> 

Original issue reported on code.google.com by mmccur...@gmail.com on 25 Aug 2010 at 8:45

GoogleCodeExporter commented 9 years ago

Original comment by mmccur...@gmail.com on 25 Aug 2010 at 8:47

GoogleCodeExporter commented 9 years ago
Fixed and checked in.  Tested on SQL Server 2008 r2(windows)

Original comment by mmccur...@gmail.com on 25 Aug 2010 at 9:21