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 Re: Missing commit after select won't update cache
Date Fri, 19 Mar 2010 10:31:42 GMT
I created IBATIS-763. 

Björn

On Mar 19, 2010, at 6:21 AM, lawouc wrote:

> 
> I'm experiencing the same issue as Björn.  Can someone tell me if issuing a
> session.commit(); is the proper way to ensure the results of a query are
> cached?  Is there any round trip to the database with an iBatis commit after
> a select?  If not, then I'll modify my code to commit after every statement,
> not just Inserts, Updates, and Deletes.  If there is a database call
> associated with a commit after a select, then that would be inefficient, at
> least in the Oracle world.  I'm also using iBatis 3 beta 10.
> 
> Many thanks.
> 
> 
> [e2n] software | Björn Raupach wrote:
>> 
>> 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
>> 
>> 
> 
> -- 
> View this message in context: http://old.nabble.com/Missing-commit-after-select-won%27t-update-cache-tp27930507p27950897.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
> 
> 


---------------------------------------------------------------------
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