ibatis-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jerome Jacobsen (JIRA)" <ibatis-...@incubator.apache.org>
Subject [jira] Created: (IBATIS-362) LRU cache broken for stored procedures
Date Mon, 30 Oct 2006 19:24:59 GMT
LRU cache broken for stored procedures

                 Key: IBATIS-362
                 URL: http://issues.apache.org/jira/browse/IBATIS-362
             Project: iBatis for Java
          Issue Type: Bug
          Components: SQL Maps
    Affects Versions: 2.2.0
         Environment: Windows 2000, JDK 1.4.2_03, JDeveloper, Spring 2.0
            Reporter: Jerome Jacobsen

I've upgraded my project 
from Spring 1.2.2,  Ibatis 2.1.5
to Spring 2.0,  Ibatis 2.2.0 (build 638)

I have a Stored Procedure which returns one OUT parameter of type String.  The procedure is
setup with LRU caching.  This works fine in Ibatis 2.1.5.  However in Ibatis 2.2.0 on the
second call to the stored procedure (with the same param values) it returns an empty string
instead of the value it got from the database.  If I disable caching this problem disappears.

. . .
  public String authenticateUser(Long cookie_in, String procedure_name)
    HashMap criteria = new HashMap();
    criteria.put("cookie_in", cookie_in);
    criteria.put("procedure_name", procedure_name);
    criteria.put("result", "");

    getSqlMapClientTemplate().queryForObject("authenticateUserDebug", criteria);
    String result = (String)criteria.get("result");
    return result;
. . .

 . . .
  <parameterMap id="authenticateUserParameters" class="map">
    <parameter property="cookie_in" jdbcType="NUMBER" javaType="java.lang.Long" mode="IN"/>
    <parameter property="procedure_name" jdbcType="VARCHAR" javaType="java.lang.String"
    <parameter property="result" jdbcType="VARCHAR" javaType="java.lang.String" mode="OUT"/>
  <procedure id="authenticateUserDebug" 
    {call DS_TEST.AUTH_SEC_CHECK(?, ?, ?)}
. . .

<sqlMapConfig xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <settings cacheModelsEnabled="true"
              lazyLoadingEnabled="false" />    
	<sqlMap resource="com/.../dao/db/ibatis/Authentication.xml"/>

Logging output looks like this on first call:
2006-10-30 14:14:31,850 DEBUG [com.ibatis.sqlmap.engine.cache.CacheModel] - <Cache 'Authentication.authentication-cache':
cache miss>
2006-10-30 14:14:31,860 DEBUG [java.sql.Connection] - <{conn-100032} Preparing Call: {call
2006-10-30 14:14:32,371 DEBUG [java.sql.PreparedStatement] - <{pstm-100033} Executing Statement:
{call DS_TEST.AUTH_SEC_CHECK(?, ?, ?)}>
2006-10-30 14:14:32,371 DEBUG [java.sql.PreparedStatement] - <{pstm-100033} Parameters:
2006-10-30 14:14:32,371 DEBUG [java.sql.PreparedStatement] - <{pstm-100033} Types: [java.lang.Long,
2006-10-30 14:14:32,451 DEBUG [com.ibatis.sqlmap.engine.cache.CacheModel] - <Cache 'Authentication.authentication-cache':
stored object 'java.lang.Object@1e8614a'>
2006-10-30 14:14:32,461 DEBUG [com.giv.dashMaintenance.dao.db.ibatis.SqlMapAuthenticationDAO]
- <result=[ACCEPTED]>

Note that it is getting the result from the database above.

And like this on subsequent calls:
2006-10-30 14:15:46,893 DEBUG [com.ibatis.sqlmap.engine.cache.CacheModel] - <Cache 'Authentication.authentication-cache':
retrieved object 'java.lang.Object@1e8614a'>
2006-10-30 14:15:46,893 DEBUG [com.giv.dashMaintenance.dao.db.ibatis.SqlMapAuthenticationDAO]
- <result=[]>

Note that the above call is getting an empty String from the cache!  

Again, in SqlMaps 2.1.5 the above works correctly.

I find the CacheModel logs interesting.  They seem to be indicating that they are caching
the *input* value (empty string) for the OUT parameter "result".  I would expect the OUTput
value of "result" to be cached instead as it was in SqlMaps 2.1.5.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


View raw message