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.

with kind regards
Björn
---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org
For additional commands, e-mail: user-java-h...@ibatis.apache.org

Reply via email to