ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Björn Raupach <raup...@e2n.de>
Subject Missing commit after select won't update cache
Date Wed, 17 Mar 2010 11:10:20 GMT
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-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Mime
View raw message