Mybatis cannot be turned off by Cacheenabled=false when using Redis as a level two cache

Source: Internet
Author: User

<?XML version= "1.0" encoding= "UTF-8"?><!DOCTYPE Configuration Public "-// Config 3.0//en" "Http://" ><Configuration>    <Settings>        <!--whether to turn on level two cache default to True -        <settingname= "cacheenabled"value= "false"/>        <!--whether lazy loading -        <settingname= "lazyloadingenabled"value= "false" />    </Settings></Configuration>

Even so, when my mappler inside has <cache type= ""/> When you query this table, I found MyBatis still checking redis.

# # # Error querying database. get Jedis connection; Nested exception is java.lang.nullpointerexception### cause: get Jedis connection; Nested exception is Java.lang.NullPointerExceptionat org.apache.ibatis.exceptions.ExceptionFactory.wrapException ( at Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList ( at Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList ( at Org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne ( at Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at Sun.reflect.NativeMethodAccessorImpl.invoke ( at Sun.reflect.DelegatingMethodAccessorImpl.invoke ( at Java.lang.reflect.Method.invoke ( at ORG.MYBATIS.SPRing. Sqlsessiontemplate$sqlsessioninterceptor.invoke ( ... morecaused get Jedis connection; Nested exception is Java.lang.NullPointerExceptionat ( at ( ( at Org.apache.ibatis.cache.decorators.LoggingCache.getObject ( at Org.apache.ibatis.cache.decorators.TransactionalCache.getObject ( at Org.apache.ibatis.cache.TransactionalCacheManager.getObject ( at Org.apache.ibatis.executor.CachingExecutor.query ( at Org.apache.ibatis.executor.CachingExecutor.query ( at Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList ( morecaused By:java.lang.NullPointerExceptionat redis.clients.jedis.binaryjedis.<init> ( : 101) at redis.clients.jedis.jedis.<init> ( at (

According to the exception stack, see the following code in CACHINGEXECUTOR.JAVA:101

@Override Public<E> list<e>query (mappedstatement MS, Object Parameterobject, Rowbounds rowbounds, Resulthandler Resulthandler, CacheKey key, Bo Undsql boundsql)throwsSQLException {Cache cache=Ms.getcache (); if(Cache! =NULL) {flushcacheifrequired (MS); if(Ms.isusecache () && Resulthandler = =NULL) {Ensurenooutparams (MS, Parameterobject, Boundsql); @SuppressWarnings ("Unchecked") List<E> list = (list<e>) Tcm.getobject (cache, key); if(List = =NULL) {List= delegate.<e>query (MS, Parameterobject, Rowbounds, Resulthandler, Key, Boundsql); Tcm.putobject (cache, key, list); //issue #578 and #116        }        returnlist; }    }    returnDelegate.<e>query (MS, Parameterobject, Rowbounds, Resulthandler, Key, Boundsql); }

So I thought, here's the cache variable if it's null.

Mybatis cannot be turned off by Cacheenabled=false when using Redis as a level two cache

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.