iBatis for .NET
  1. iBatis for .NET
  2. IBATISNET-299

Read/write, nonserializable caching generates a new cache key for each request

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: DataMapper 1.6.2
    • Fix Version/s: None
    • Component/s: DataMapper
    • Labels:
      None

      Description

      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>

        Activity

        Hide
        Steven Cottrell added a comment - - edited

        Attaching a patch for this issue. The patch is against the http://svn.apache.org/repos/asf/ibatis/cs/ibatisnet-1/trunk repository, rev 903789

        Show
        Steven Cottrell added a comment - - edited Attaching a patch for this issue. The patch is against the http://svn.apache.org/repos/asf/ibatis/cs/ibatisnet-1/trunk repository, rev 903789
        Hide
        Steven Cottrell added a comment -

        I have checked out the current 1.x trunk and coded a fix (with tests!) for this, however I am unsure as to the best way to get it into the trunk. I could not see on the iBatis wiki or mailing list how to sign up for a Subversion account.

        Can you please contact me or comment to this issue letting me know how I can submit my fix?

        The fix is minor and consists of changes to these files:
        IBatisNet.DataMapper/MappedStatements/CachingStatement.cs
        IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheTest.cs

        and all the Account.xml files (to add a read/write, nonserializable cache model and a statement that uses it)
        IBatisNet.DataMapper.Test/Maps/Access/OleDb/Account.xml
        IBatisNet.DataMapper.Test/Maps/MSSQL/OdbcAccount.xml
        IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb/Account.xml
        IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml
        IBatisNet.DataMapper.Test/Maps/MySql/ByteFx/Account.xml
        IBatisNet.DataMapper.Test/Maps/MySql/MySql/Account.xml
        IBatisNet.DataMapper.Test/Maps/Oracle/ODP/Account.xml
        IBatisNet.DataMapper.Test/Maps/Oracle/OracleClient/Account.xml
        IBatisNet.DataMapper.Test/Maps/PostgreSQL/Npgsql/Account.xml

        Show
        Steven Cottrell added a comment - I have checked out the current 1.x trunk and coded a fix (with tests!) for this, however I am unsure as to the best way to get it into the trunk. I could not see on the iBatis wiki or mailing list how to sign up for a Subversion account. Can you please contact me or comment to this issue letting me know how I can submit my fix? The fix is minor and consists of changes to these files: IBatisNet.DataMapper/MappedStatements/CachingStatement.cs IBatisNet.DataMapper.Test/NUnit/SqlMapTests/CacheTest.cs and all the Account.xml files (to add a read/write, nonserializable cache model and a statement that uses it) IBatisNet.DataMapper.Test/Maps/Access/OleDb/Account.xml IBatisNet.DataMapper.Test/Maps/MSSQL/OdbcAccount.xml IBatisNet.DataMapper.Test/Maps/MSSQL/OleDb/Account.xml IBatisNet.DataMapper.Test/Maps/MSSQL/SqlClient/Account.xml IBatisNet.DataMapper.Test/Maps/MySql/ByteFx/Account.xml IBatisNet.DataMapper.Test/Maps/MySql/MySql/Account.xml IBatisNet.DataMapper.Test/Maps/Oracle/ODP/Account.xml IBatisNet.DataMapper.Test/Maps/Oracle/OracleClient/Account.xml IBatisNet.DataMapper.Test/Maps/PostgreSQL/Npgsql/Account.xml

          People

          • Assignee:
            Unassigned
            Reporter:
            Steven Cottrell
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Development