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 "-//mybatis.org//dtd Config 3.0//en" "Http://mybatis.org/dtd/mybatis-3-config.dtd" ><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= "Com.springbank.dao.support.cache.redis.RedisCache"/> When you query this table, I found MyBatis still checking redis.

# # # Error querying database. Cause:org.springframework.data.redis.RedisConnectionFailureException:Cannot get Jedis connection; Nested exception is java.lang.nullpointerexception### cause: Org.springframework.data.redis.RedisConnectionFailureException:Cannot get Jedis connection; Nested exception is Java.lang.NullPointerExceptionat org.apache.ibatis.exceptions.ExceptionFactory.wrapException ( exceptionfactory.java:30) at Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList ( defaultsqlsession.java:150) at Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList ( defaultsqlsession.java:141) at Org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne ( defaultsqlsession.java:77) at Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at Sun.reflect.NativeMethodAccessorImpl.invoke (nativemethodaccessorimpl.java:62) at Sun.reflect.DelegatingMethodAccessorImpl.invoke (delegatingmethodaccessorimpl.java:43) at Java.lang.reflect.Method.invoke (method.java:498) at ORG.MYBATIS.SPRing. Sqlsessiontemplate$sqlsessioninterceptor.invoke (sqlsessiontemplate.java:434) ... morecaused by:org.springframework.data.redis.RedisConnectionFailureException:Cannot get Jedis connection; Nested exception is Java.lang.NullPointerExceptionat Org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector ( jedisconnectionfactory.java:198) at Org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection ( jedisconnectionfactory.java:345)At Com.springbank.dao.support.cache.redis.RedisCache.getObject (rediscache.java:62) at Org.apache.ibatis.cache.decorators.LoggingCache.getObject (loggingcache.java:57) at Org.apache.ibatis.cache.decorators.TransactionalCache.getObject (transactionalcache.java:68) at Org.apache.ibatis.cache.TransactionalCacheManager.getObject (transactionalcachemanager.java:35) at Org.apache.ibatis.executor.CachingExecutor.query (cachingexecutor.java:101) at Org.apache.ibatis.executor.CachingExecutor.query (cachingexecutor.java:83) at Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList (defaultsqlsession.java:148)... morecaused By:java.lang.NullPointerExceptionat redis.clients.jedis.binaryjedis.<init> (Binaryjedis.java : 101) at redis.clients.jedis.jedis.<init> (jedis.java:78) at Org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector ( jedisconnectionfactory.java:193)

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: info-contact@alibabacloud.com 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.