Uploaded image for project: 'iBatis for Java [READ ONLY]'
  1. iBatis for Java [READ ONLY]
  2. IBATIS-763

Missing commit after select won't update cache

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0 Beta 10
    • 3.0 GA Candidate
    • Core
    • None

    Description

      Hello,

      just wanted to check if this behavior is on purpose.

      For select Statements I use the following construct in my DAO.

      public List<Job> selectJobs() {
      List<Job> resultList = null;
      SqlSession session = getSqlSessionFactory().openSession();
      try

      { JobMapper mapper = session.getMapper(JobMapper.class); resultList = mapper.selectJobs(); }

      finally

      { session.close(); }

      return resultList;
      }

      <cache /> is set in the JobMapper.xml.

      Calling this method twice in my Unit Test results the following Log
      Message:
      // first call
      org.apache.ibatis.cache.decorators.LoggingCache - Cache Hit Ratio
      [de.zmi.data.batis.JobMapper]: 0.0
      // second call
      org.apache.ibatis.cache.decorators.LoggingCache - Cache Hit Ratio
      [de.zmi.data.batis.JobMapper]: 0.0

      Appending session.commit() after mapper.selectJobs() results in:
      // first call
      org.apache.ibatis.cache.decorators.LoggingCache - Cache Hit Ratio
      [de.zmi.data.batis.JobMapper]: 0.0
      // second call
      org.apache.ibatis.cache.decorators.LoggingCache - Cache Hit Ratio
      [de.zmi.data.batis.JobMapper]: 0.5

      So the second call is using the cache. I thought commit is only needed for
      update/insert or delete statements.

      I am using iBatis 3 - Beta 10.

      Attachments

        Activity

          People

            cbegin Clinton Begin
            raupach Björn Raupach
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: