ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From De Gaetano Giuseppe <degaet...@PITAGORA.IT>
Subject R: chache problem
Date Thu, 17 Jul 2008 13:10:46 GMT
Sorry for chache in the subject :)
I attach also the java code I use as parameter class

________________________________
Da: De Gaetano Giuseppe [mailto:degaetano@pitagora.it]
Inviato: giovedì 17 luglio 2008 15.06
A: user-java@ibatis.apache.org
Oggetto: chache problem

Hi guys I have a problem using the cache.

This is my configuration:

sql-map-config.xml


  <settings useStatementNamespaces="true"/>

  <transactionManager type="JDBC">
    <dataSource type="SIMPLE">
      <property value="${driver}" name="JDBC.Driver"/>
      <property value="${url}" name="JDBC.ConnectionURL"/>
      <property value="${username}" name="JDBC.Username"/>
      <property value="${password}" name="JDBC.Password"/>
      </dataSource>
  </transactionManager>

<sqlMap resource="TMP_TEST_CACHE_IBATIS_SqlMap.xml" />


TMP_TEST_CACHE_IBATIS_SqlMap.xml

<sqlMap namespace="TMP_TEST_CACHE_IBATIS" >
  <cacheModel id="TmpTestCacheIbatis_cache" type="MEMORY" readOnly="true" serialize="false"
>
    <flushInterval hours="1" />
    <property name="size" value="100" />
  </cacheModel>
  <resultMap id="TmpTestCacheIbatisResult" class="it.pitagora.ibatis.TmpTestCacheIbatis"
>
    <result column="AAA" property="aaa" jdbcType="VARCHAR" />
    <result column="BBB" property="bbb" jdbcType="VARCHAR" />
  </resultMap>

   <select id="selectByAllPropertiesConCache" resultMap="TmpTestCacheIbatisResult" parameterClass="it.pitagora.ibatis.TmpTestCacheIbatis"
cacheModel="TmpTestCacheIbatis_cache">
    select AAA, BBB from TMP_TEST_CACHE_IBATIS
    where
    (AAA = #aaa:VARCHAR# or AAA is null)
    and
    (BBB = #bbb:VARCHAR# or BBB is null)
  </select>


This is the db configuration
      CREATE TABLE TMP_TEST_CACHE_IBATIS
      (
        AAA            VARCHAR2(1) ,
        BBB            VARCHAR2(2)
      );

      insert into TMP_TEST_CACHE_IBATIS (AAA, BBB ) values ('A', null);
      insert into TMP_TEST_CACHE_IBATIS (AAA, BBB ) values (null, 'B');
      insert into TMP_TEST_CACHE_IBATIS (AAA, BBB ) values (null,null);


If I execute the following code

TmpTestCacheIbatis searchParam = new TmpTestCacheIbatis();
searchParam.setAaa("A");
List<TmpTestCacheIbatis> list = (List<TmpTestCacheIbatis>)sqlMap.queryForList("TMP_TEST_CACHE_IBATIS.selectByAllPropertiesConCache",
searchParam);
System.out.println("params="+searchParam+" --> result="+list);


TmpTestCacheIbatis searchParam2 = new TmpTestCacheIbatis();
searchParam2.setBbb("A");
List<TmpTestCacheIbatis> list2 = (List<TmpTestCacheIbatis>)sqlMap.queryForList("TMP_TEST_CACHE_IBATIS.selectByAllPropertiesConCache",
searchParam2);
System.out.println("params="+searchParam2+" --> result="+list2);

I get a wrong result as you can see from the following log:

MSG;537351365;5962608;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:03:26,340;{conn-100000}
Connection
MSG;537351365;5962608;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:03:26,418;{conn-100000}
Preparing Statement:      select AAA, BBB from TMP_TEST_CACHE_IBATIS     where      (AAA =
? or AAA is null)     and      (BBB = ? or BBB is null)
MSG;537351365;5962608;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:03:26,652;{pstm-100001}
Executing Statement:      select AAA, BBB from TMP_TEST_CACHE_IBATIS     where      (AAA =
? or AAA is null)     and      (BBB = ? or BBB is null)
MSG;537351365;5962608;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:03:26,652;{pstm-100001}
Parameters: [A, null]
MSG;537351365;5962608;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:03:26,652;{pstm-100001}
Types: [java.lang.String, null]
MSG;537351365;5962608;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:03:26,684;{rset-100002}
ResultSet
MSG;537351365;5962608;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:03:26,777;{rset-100002}
Header: [AAA, BBB]
MSG;537351365;5962608;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:03:26,777;{rset-100002}
Result: [A, null]
MSG;537351365;5962608;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:03:26,777;{rset-100002}
Result: [null, null]
MSG;537351365;5962608;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:03:26,777;Cache 'TMP_TEST_CACHE_IBATIS.TmpTestCacheIbatis_cache':
stored object '[[aaa=A,bbb=null], [aaa=null,bbb=null]]'
params=[aaa=A,bbb=null] --> result=[[aaa=A,bbb=null], [aaa=null,bbb=null]]
MSG;537351365;5962608;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:03:26,777;Cache 'TMP_TEST_CACHE_IBATIS.TmpTestCacheIbatis_cache':
retrieved object '[[aaa=A,bbb=null], [aaa=null,bbb=null]]'
params=[aaa=null,bbb=A] --> result=[[aaa=A,bbb=null], [aaa=null,bbb=null]] ERRORE

If I execute the following code, I don't get the problem anymore as you can see:
TmpTestCacheIbatis searchParam1 = new TmpTestCacheIbatis();
searchParam1.setBbb("B");
List<TmpTestCacheIbatis> list1 = (List<TmpTestCacheIbatis>)sqlMap.queryForList("TMP_TEST_CACHE_IBATIS.selectByAllPropertiesConCache",
searchParam1);
System.out.println("params="+searchParam1+" --> result="+list1);

TmpTestCacheIbatis searchParam2 = new TmpTestCacheIbatis();
searchParam2.setBbb("A");
List<TmpTestCacheIbatis> list2 = (List<TmpTestCacheIbatis>)sqlMap.queryForList("TMP_TEST_CACHE_IBATIS.selectByAllPropertiesConCache",
searchParam2);
System.out.println("params="+searchParam2+" --> result="+list2);


MSG;922621065;1879483962;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:00:42,934;{conn-100000}
Connection
MSG;922621065;1879483962;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:00:42,980;{conn-100000}
Preparing Statement:      select AAA, BBB from TMP_TEST_CACHE_IBATIS     where      (AAA =
? or AAA is null)     and      (BBB = ? or BBB is null)
MSG;922621065;1879483962;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:00:43,230;{pstm-100001}
Executing Statement:      select AAA, BBB from TMP_TEST_CACHE_IBATIS     where      (AAA =
? or AAA is null)     and      (BBB = ? or BBB is null)
MSG;922621065;1879483962;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:00:43,230;{pstm-100001}
Parameters: [null, B]
MSG;922621065;1879483962;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:00:43,230;{pstm-100001}
Types: [null, java.lang.String]
MSG;922621065;1879483962;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:00:43,246;{rset-100002}
ResultSet
MSG;922621065;1879483962;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:00:43,340;{rset-100002}
Header: [AAA, BBB]
MSG;922621065;1879483962;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:00:43,340;{rset-100002}
Result: [null, B]
MSG;922621065;1879483962;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:00:43,355;{rset-100002}
Result: [null, null]
MSG;922621065;1879483962;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:00:43,355;Cache
'TMP_TEST_CACHE_IBATIS.TmpTestCacheIbatis_cache': stored object '[[aaa=null,bbb=B], [aaa=null,bbb=null]]'
params=[aaa=null,bbb=B] --> result=[[aaa=null,bbb=B], [aaa=null,bbb=null]]
MSG;922621065;1879483962;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:00:43,355;Cache
'TMP_TEST_CACHE_IBATIS.TmpTestCacheIbatis_cache': cache miss
MSG;922621065;1879483962;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:00:43,355;{conn-100003}
Connection
MSG;922621065;1879483962;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:00:43,355;{conn-100003}
Preparing Statement:      select AAA, BBB from TMP_TEST_CACHE_IBATIS     where      (AAA =
? or AAA is null)     and      (BBB = ? or BBB is null)
MSG;922621065;1879483962;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:00:43,355;{pstm-100004}
Executing Statement:      select AAA, BBB from TMP_TEST_CACHE_IBATIS     where      (AAA =
? or AAA is null)     and      (BBB = ? or BBB is null)
MSG;922621065;1879483962;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:00:43,355;{pstm-100004}
Parameters: [null, A]
MSG;922621065;1879483962;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:00:43,355;{pstm-100004}
Types: [null, java.lang.String]
MSG;922621065;1879483962;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:00:43,355;{rset-100005}
ResultSet
MSG;922621065;1879483962;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:00:43,355;{rset-100005}
Header: [AAA, BBB]
MSG;922621065;1879483962;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:00:43,355;{rset-100005}
Result: [null, null]
MSG;922621065;1879483962;null;JakartaCommonsLoggingImpl.debug;17/07/2008 15:00:43,355;Cache
'TMP_TEST_CACHE_IBATIS.TmpTestCacheIbatis_cache': stored object '[[aaa=null,bbb=null]]'
params=[aaa=null,bbb=A] --> result=[[aaa=null,bbb=null]]

Is there anyone that could help me.

Thanks in advance.
Giuseppe

Ps. I am using ibatis 2.3.3, but I also tried 2.3.2 and 2.2.0


Mime
View raw message