You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by "Jerome Jacobsen (JIRA)" <ib...@incubator.apache.org> on 2006/10/30 20:24:59 UTC

[jira] Created: (IBATIS-362) LRU cache broken for stored procedures

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 9.0.5.2, 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.

SqlMapAuthenticationDAO.java:
. . .
  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;
  }
. . .

Authentication.xml:
 . . .
  <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" mode="IN"/>
    <parameter property="result" jdbcType="VARCHAR" javaType="java.lang.String" mode="OUT"/>
  </parameterMap>
  <procedure id="authenticateUserDebug" 
    parameterMap="authenticateUserParameters" 
    cacheModel="authentication-cache">
    {call DS_TEST.AUTH_SEC_CHECK(?, ?, ?)}
  </procedure>
. . .

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

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 DS_TEST.AUTH_SEC_CHECK(?, ?, ?)}>
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: [12345, DASHBOARD_MAINT_WEB.LOAD_REC_ITEMS]>
2006-10-30 14:14:32,371 DEBUG [java.sql.PreparedStatement] - <{pstm-100033} Types: [java.lang.Long, java.lang.String]>
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

        

[jira] Closed: (IBATIS-362) LRU cache broken for stored procedures

Posted by "Clinton Begin (JIRA)" <ib...@incubator.apache.org>.
     [ https://issues.apache.org/jira/browse/IBATIS-362?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Clinton Begin closed IBATIS-362.
--------------------------------

    Resolution: Won't Fix

The reason it "worked" in 2.1.5 is that procs weren't cached at all.  In 2.2.0+ proc statements were cached, but there's no way to cache output parameters, as you're passing the object in (so we can't cache it).  We could build something in to mock the parameter object (e.g. keep the values in a map)and hold the out params, but that's nontrivial.  So for now, no, there is no way to cache output parameters.  You can cache regular results from a proc of course, just not the OUT params...

This could be a feature request, but I'm not confident that it would ever make it into the 2.x release... possibly in 3.0. 

Clinton


> LRU cache broken for stored procedures
> --------------------------------------
>
>                 Key: IBATIS-362
>                 URL: https://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 9.0.5.2, 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.
> SqlMapAuthenticationDAO.java:
> . . .
>   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;
>   }
> . . .
> Authentication.xml:
>  . . .
>   <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" mode="IN"/>
>     <parameter property="result" jdbcType="VARCHAR" javaType="java.lang.String" mode="OUT"/>
>   </parameterMap>
>   <procedure id="authenticateUserDebug" 
>     parameterMap="authenticateUserParameters" 
>     cacheModel="authentication-cache">
>     {call DS_TEST.AUTH_SEC_CHECK(?, ?, ?)}
>   </procedure>
> . . .
> sql-map-config-authentication.xml:
> <sqlMapConfig xmlns:fo="http://www.w3.org/1999/XSL/Format">
>     <settings cacheModelsEnabled="true"
>               lazyLoadingEnabled="false" />    
> 	<sqlMap resource="com/.../dao/db/ibatis/Authentication.xml"/>
> </sqlMapConfig>
> 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 DS_TEST.AUTH_SEC_CHECK(?, ?, ?)}>
> 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: [12345, DASHBOARD_MAINT_WEB.LOAD_REC_ITEMS]>
> 2006-10-30 14:14:32,371 DEBUG [java.sql.PreparedStatement] - <{pstm-100033} Types: [java.lang.Long, java.lang.String]>
> 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.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (IBATIS-362) LRU cache broken for stored procedures

Posted by "Jason Bennett (JIRA)" <ib...@incubator.apache.org>.
    [ https://issues.apache.org/jira/browse/IBATIS-362?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12590628#action_12590628 ] 

Jason Bennett commented on IBATIS-362:
--------------------------------------

I concerned that there hasn't been any discussion or progress on this issue. I ran into it myself this week.

If stored procedure results are not supposed to be cached, the DTD should be changed to prevent that. If they are, this bug should be fixed so invalid values are not returned.

I did try multiple cache types (including FIFO and MEMORY) and replicated the error with each of them, so it is not LRU specific.

> LRU cache broken for stored procedures
> --------------------------------------
>
>                 Key: IBATIS-362
>                 URL: https://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 9.0.5.2, 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.
> SqlMapAuthenticationDAO.java:
> . . .
>   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;
>   }
> . . .
> Authentication.xml:
>  . . .
>   <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" mode="IN"/>
>     <parameter property="result" jdbcType="VARCHAR" javaType="java.lang.String" mode="OUT"/>
>   </parameterMap>
>   <procedure id="authenticateUserDebug" 
>     parameterMap="authenticateUserParameters" 
>     cacheModel="authentication-cache">
>     {call DS_TEST.AUTH_SEC_CHECK(?, ?, ?)}
>   </procedure>
> . . .
> sql-map-config-authentication.xml:
> <sqlMapConfig xmlns:fo="http://www.w3.org/1999/XSL/Format">
>     <settings cacheModelsEnabled="true"
>               lazyLoadingEnabled="false" />    
> 	<sqlMap resource="com/.../dao/db/ibatis/Authentication.xml"/>
> </sqlMapConfig>
> 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 DS_TEST.AUTH_SEC_CHECK(?, ?, ?)}>
> 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: [12345, DASHBOARD_MAINT_WEB.LOAD_REC_ITEMS]>
> 2006-10-30 14:14:32,371 DEBUG [java.sql.PreparedStatement] - <{pstm-100033} Types: [java.lang.Long, java.lang.String]>
> 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.
-
You can reply to this email to add a comment to the issue online.