类 MybatisConfiguration


  • public class MybatisConfiguration
    extends org.apache.ibatis.session.Configuration
    replace default Configuration class

    Caratacus 2016/9/25 replace mapperRegistry

    从以下版本开始:
    2016-01-23
    作者:
    hubin
    • 字段概要

      字段 
      修饰符和类型 字段 说明
      protected java.util.Map<java.lang.String,​org.apache.ibatis.cache.Cache> caches  
      protected java.util.Map<java.lang.String,​org.apache.ibatis.executor.keygen.KeyGenerator> keyGenerators  
      protected java.util.Map<java.lang.String,​org.apache.ibatis.mapping.MappedStatement> mappedStatements  
      protected MybatisMapperRegistry mybatisMapperRegistry
      Mapper 注册
      protected java.util.Map<java.lang.String,​org.apache.ibatis.mapping.ParameterMap> parameterMaps  
      protected java.util.Map<java.lang.String,​org.apache.ibatis.mapping.ResultMap> resultMaps  
      protected java.util.Map<java.lang.String,​org.apache.ibatis.parsing.XNode> sqlFragments  
      • 从类继承的字段 org.apache.ibatis.session.Configuration

        aggressiveLazyLoading, autoMappingBehavior, autoMappingUnknownColumnBehavior, cacheEnabled, cacheRefMap, callSettersOnNulls, configurationFactory, databaseId, defaultExecutorType, defaultFetchSize, defaultResultSetType, defaultSqlProviderType, defaultStatementTimeout, environment, incompleteCacheRefs, incompleteMethods, incompleteResultMaps, incompleteStatements, interceptorChain, jdbcTypeForNull, languageRegistry, lazyLoadingEnabled, lazyLoadTriggerMethods, loadedResources, localCacheScope, logImpl, logPrefix, mapperRegistry, mapUnderscoreToCamelCase, multipleResultSetsEnabled, nullableOnForEach, objectFactory, objectWrapperFactory, proxyFactory, reflectorFactory, returnInstanceForEmptyRow, safeResultHandlerEnabled, safeRowBoundsEnabled, shrinkWhitespacesInSql, typeAliasRegistry, typeHandlerRegistry, useActualParamName, useColumnLabel, useGeneratedKeys, variables, vfsImpl
    • 方法概要

      所有方法 实例方法 具体方法 
      修饰符和类型 方法 说明
      void addCache​(org.apache.ibatis.cache.Cache cache)  
      void addKeyGenerator​(java.lang.String id, org.apache.ibatis.executor.keygen.KeyGenerator keyGenerator)  
      void addMappedStatement​(org.apache.ibatis.mapping.MappedStatement ms)
      MybatisPlus 加载 SQL 顺序:
      <T> void addMapper​(java.lang.Class<T> type)
      使用自己的 MybatisMapperRegistry
      void addMappers​(java.lang.String packageName)
      使用自己的 MybatisMapperRegistry
      void addMappers​(java.lang.String packageName, java.lang.Class<?> superType)
      使用自己的 MybatisMapperRegistry
      <T> void addNewMapper​(java.lang.Class<T> type)
      新增注入新的 Mapper 信息,新增前会清理之前的缓存信息
      void addParameterMap​(org.apache.ibatis.mapping.ParameterMap pm)  
      void addResultMap​(org.apache.ibatis.mapping.ResultMap rm)  
      protected void checkGloballyForDiscriminatedNestedResultMaps​(org.apache.ibatis.mapping.ResultMap rm)  
      protected void checkLocallyForDiscriminatedNestedResultMaps​(org.apache.ibatis.mapping.ResultMap rm)  
      org.apache.ibatis.cache.Cache getCache​(java.lang.String id)  
      java.util.Collection<java.lang.String> getCacheNames()  
      java.util.Collection<org.apache.ibatis.cache.Cache> getCaches()  
      org.apache.ibatis.executor.keygen.KeyGenerator getKeyGenerator​(java.lang.String id)  
      java.util.Collection<java.lang.String> getKeyGeneratorNames()  
      java.util.Collection<org.apache.ibatis.executor.keygen.KeyGenerator> getKeyGenerators()  
      org.apache.ibatis.mapping.MappedStatement getMappedStatement​(java.lang.String id)  
      org.apache.ibatis.mapping.MappedStatement getMappedStatement​(java.lang.String id, boolean validateIncompleteStatements)  
      java.util.Collection<java.lang.String> getMappedStatementNames()  
      java.util.Collection<org.apache.ibatis.mapping.MappedStatement> getMappedStatements()  
      <T> T getMapper​(java.lang.Class<T> type, org.apache.ibatis.session.SqlSession sqlSession)
      使用自己的 MybatisMapperRegistry
      org.apache.ibatis.binding.MapperRegistry getMapperRegistry()
      使用自己的 MybatisMapperRegistry
      org.apache.ibatis.mapping.ParameterMap getParameterMap​(java.lang.String id)  
      java.util.Collection<java.lang.String> getParameterMapNames()  
      java.util.Collection<org.apache.ibatis.mapping.ParameterMap> getParameterMaps()  
      org.apache.ibatis.mapping.ResultMap getResultMap​(java.lang.String id)  
      java.util.Collection<java.lang.String> getResultMapNames()  
      java.util.Collection<org.apache.ibatis.mapping.ResultMap> getResultMaps()  
      java.util.Map<java.lang.String,​org.apache.ibatis.parsing.XNode> getSqlFragments()  
      boolean hasCache​(java.lang.String id)  
      boolean hasKeyGenerator​(java.lang.String id)  
      boolean hasMapper​(java.lang.Class<?> type)
      使用自己的 MybatisMapperRegistry
      boolean hasParameterMap​(java.lang.String id)  
      boolean hasResultMap​(java.lang.String id)  
      boolean hasStatement​(java.lang.String statementName, boolean validateIncompleteStatements)  
      boolean isUseGeneratedShortKey()
      是否生成短key缓存
      org.apache.ibatis.executor.Executor newExecutor​(org.apache.ibatis.transaction.Transaction transaction, org.apache.ibatis.session.ExecutorType executorType)  
      <T> void removeMapper​(java.lang.Class<T> type)
      移除 Mapper 相关缓存,支持 GroovyClassLoader 动态注入 Mapper
      void setDefaultScriptingLanguage​(java.lang.Class<? extends org.apache.ibatis.scripting.LanguageDriver> driver)
      指定动态SQL生成的默认语言
      void setUseGeneratedShortKey​(boolean useGeneratedShortKey)
      是否生成短key缓存
      • 从类继承的方法 org.apache.ibatis.session.Configuration

        addCacheRef, addIncompleteCacheRef, addIncompleteMethod, addIncompleteResultMap, addIncompleteStatement, addInterceptor, addLoadedResource, buildAllStatements, extractNamespace, getAutoMappingBehavior, getAutoMappingUnknownColumnBehavior, getConfigurationFactory, getDatabaseId, getDefaultExecutorType, getDefaultFetchSize, getDefaultResultSetType, getDefaultScriptingLanguageInstance, getDefaultScriptingLanuageInstance, getDefaultSqlProviderType, getDefaultStatementTimeout, getEnvironment, getIncompleteCacheRefs, getIncompleteMethods, getIncompleteResultMaps, getIncompleteStatements, getInterceptors, getJdbcTypeForNull, getLanguageDriver, getLanguageRegistry, getLazyLoadTriggerMethods, getLocalCacheScope, getLogImpl, getLogPrefix, getObjectFactory, getObjectWrapperFactory, getProxyFactory, getReflectorFactory, getTypeAliasRegistry, getTypeHandlerRegistry, getVariables, getVfsImpl, hasStatement, isAggressiveLazyLoading, isCacheEnabled, isCallSettersOnNulls, isLazyLoadingEnabled, isMapUnderscoreToCamelCase, isMultipleResultSetsEnabled, isNullableOnForEach, isResourceLoaded, isReturnInstanceForEmptyRow, isSafeResultHandlerEnabled, isSafeRowBoundsEnabled, isShrinkWhitespacesInSql, isUseActualParamName, isUseColumnLabel, isUseGeneratedKeys, newExecutor, newMetaObject, newParameterHandler, newResultSetHandler, newStatementHandler, setAggressiveLazyLoading, setAutoMappingBehavior, setAutoMappingUnknownColumnBehavior, setCacheEnabled, setCallSettersOnNulls, setConfigurationFactory, setDatabaseId, setDefaultEnumTypeHandler, setDefaultExecutorType, setDefaultFetchSize, setDefaultResultSetType, setDefaultSqlProviderType, setDefaultStatementTimeout, setEnvironment, setJdbcTypeForNull, setLazyLoadingEnabled, setLazyLoadTriggerMethods, setLocalCacheScope, setLogImpl, setLogPrefix, setMapUnderscoreToCamelCase, setMultipleResultSetsEnabled, setNullableOnForEach, setObjectFactory, setObjectWrapperFactory, setProxyFactory, setReflectorFactory, setReturnInstanceForEmptyRow, setSafeResultHandlerEnabled, setSafeRowBoundsEnabled, setShrinkWhitespacesInSql, setUseActualParamName, setUseColumnLabel, setUseGeneratedKeys, setVariables, setVfsImpl
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 字段详细资料

      • caches

        protected final java.util.Map<java.lang.String,​org.apache.ibatis.cache.Cache> caches
      • resultMaps

        protected final java.util.Map<java.lang.String,​org.apache.ibatis.mapping.ResultMap> resultMaps
      • parameterMaps

        protected final java.util.Map<java.lang.String,​org.apache.ibatis.mapping.ParameterMap> parameterMaps
      • keyGenerators

        protected final java.util.Map<java.lang.String,​org.apache.ibatis.executor.keygen.KeyGenerator> keyGenerators
      • sqlFragments

        protected final java.util.Map<java.lang.String,​org.apache.ibatis.parsing.XNode> sqlFragments
      • mappedStatements

        protected final java.util.Map<java.lang.String,​org.apache.ibatis.mapping.MappedStatement> mappedStatements
    • 构造器详细资料

      • MybatisConfiguration

        public MybatisConfiguration​(org.apache.ibatis.mapping.Environment environment)
      • MybatisConfiguration

        public MybatisConfiguration()
        初始化调用
    • 方法详细资料

      • addMappedStatement

        public void addMappedStatement​(org.apache.ibatis.mapping.MappedStatement ms)
        MybatisPlus 加载 SQL 顺序:

        1、加载 XML中的 SQL

        2、加载 SqlProvider 中的 SQL

        3、XmlSql 与 SqlProvider不能包含相同的 SQL

        调整后的 SQL优先级:XmlSql > sqlProvider > CurdSql

        覆盖:
        addMappedStatement 在类中 org.apache.ibatis.session.Configuration
      • getMapperRegistry

        public org.apache.ibatis.binding.MapperRegistry getMapperRegistry()
        使用自己的 MybatisMapperRegistry
        覆盖:
        getMapperRegistry 在类中 org.apache.ibatis.session.Configuration
      • addMapper

        public <T> void addMapper​(java.lang.Class<T> type)
        使用自己的 MybatisMapperRegistry
        覆盖:
        addMapper 在类中 org.apache.ibatis.session.Configuration
      • addNewMapper

        public <T> void addNewMapper​(java.lang.Class<T> type)
        新增注入新的 Mapper 信息,新增前会清理之前的缓存信息
        类型参数:
        T -
        参数:
        type - Mapper Type
      • removeMapper

        public <T> void removeMapper​(java.lang.Class<T> type)
        移除 Mapper 相关缓存,支持 GroovyClassLoader 动态注入 Mapper
        类型参数:
        T -
        参数:
        type - Mapper Type
      • addMappers

        public void addMappers​(java.lang.String packageName,
                               java.lang.Class<?> superType)
        使用自己的 MybatisMapperRegistry
        覆盖:
        addMappers 在类中 org.apache.ibatis.session.Configuration
      • addMappers

        public void addMappers​(java.lang.String packageName)
        使用自己的 MybatisMapperRegistry
        覆盖:
        addMappers 在类中 org.apache.ibatis.session.Configuration
      • getMapper

        public <T> T getMapper​(java.lang.Class<T> type,
                               org.apache.ibatis.session.SqlSession sqlSession)
        使用自己的 MybatisMapperRegistry
        覆盖:
        getMapper 在类中 org.apache.ibatis.session.Configuration
      • hasMapper

        public boolean hasMapper​(java.lang.Class<?> type)
        使用自己的 MybatisMapperRegistry
        覆盖:
        hasMapper 在类中 org.apache.ibatis.session.Configuration
      • setDefaultScriptingLanguage

        public void setDefaultScriptingLanguage​(java.lang.Class<? extends org.apache.ibatis.scripting.LanguageDriver> driver)
        指定动态SQL生成的默认语言
        覆盖:
        setDefaultScriptingLanguage 在类中 org.apache.ibatis.session.Configuration
        参数:
        driver - LanguageDriver
      • addKeyGenerator

        public void addKeyGenerator​(java.lang.String id,
                                    org.apache.ibatis.executor.keygen.KeyGenerator keyGenerator)
        覆盖:
        addKeyGenerator 在类中 org.apache.ibatis.session.Configuration
      • getKeyGeneratorNames

        public java.util.Collection<java.lang.String> getKeyGeneratorNames()
        覆盖:
        getKeyGeneratorNames 在类中 org.apache.ibatis.session.Configuration
      • getKeyGenerators

        public java.util.Collection<org.apache.ibatis.executor.keygen.KeyGenerator> getKeyGenerators()
        覆盖:
        getKeyGenerators 在类中 org.apache.ibatis.session.Configuration
      • getKeyGenerator

        public org.apache.ibatis.executor.keygen.KeyGenerator getKeyGenerator​(java.lang.String id)
        覆盖:
        getKeyGenerator 在类中 org.apache.ibatis.session.Configuration
      • hasKeyGenerator

        public boolean hasKeyGenerator​(java.lang.String id)
        覆盖:
        hasKeyGenerator 在类中 org.apache.ibatis.session.Configuration
      • addCache

        public void addCache​(org.apache.ibatis.cache.Cache cache)
        覆盖:
        addCache 在类中 org.apache.ibatis.session.Configuration
      • getCacheNames

        public java.util.Collection<java.lang.String> getCacheNames()
        覆盖:
        getCacheNames 在类中 org.apache.ibatis.session.Configuration
      • getCaches

        public java.util.Collection<org.apache.ibatis.cache.Cache> getCaches()
        覆盖:
        getCaches 在类中 org.apache.ibatis.session.Configuration
      • getCache

        public org.apache.ibatis.cache.Cache getCache​(java.lang.String id)
        覆盖:
        getCache 在类中 org.apache.ibatis.session.Configuration
      • hasCache

        public boolean hasCache​(java.lang.String id)
        覆盖:
        hasCache 在类中 org.apache.ibatis.session.Configuration
      • addResultMap

        public void addResultMap​(org.apache.ibatis.mapping.ResultMap rm)
        覆盖:
        addResultMap 在类中 org.apache.ibatis.session.Configuration
      • getResultMapNames

        public java.util.Collection<java.lang.String> getResultMapNames()
        覆盖:
        getResultMapNames 在类中 org.apache.ibatis.session.Configuration
      • getResultMaps

        public java.util.Collection<org.apache.ibatis.mapping.ResultMap> getResultMaps()
        覆盖:
        getResultMaps 在类中 org.apache.ibatis.session.Configuration
      • getResultMap

        public org.apache.ibatis.mapping.ResultMap getResultMap​(java.lang.String id)
        覆盖:
        getResultMap 在类中 org.apache.ibatis.session.Configuration
      • hasResultMap

        public boolean hasResultMap​(java.lang.String id)
        覆盖:
        hasResultMap 在类中 org.apache.ibatis.session.Configuration
      • addParameterMap

        public void addParameterMap​(org.apache.ibatis.mapping.ParameterMap pm)
        覆盖:
        addParameterMap 在类中 org.apache.ibatis.session.Configuration
      • getParameterMapNames

        public java.util.Collection<java.lang.String> getParameterMapNames()
        覆盖:
        getParameterMapNames 在类中 org.apache.ibatis.session.Configuration
      • getParameterMaps

        public java.util.Collection<org.apache.ibatis.mapping.ParameterMap> getParameterMaps()
        覆盖:
        getParameterMaps 在类中 org.apache.ibatis.session.Configuration
      • getParameterMap

        public org.apache.ibatis.mapping.ParameterMap getParameterMap​(java.lang.String id)
        覆盖:
        getParameterMap 在类中 org.apache.ibatis.session.Configuration
      • hasParameterMap

        public boolean hasParameterMap​(java.lang.String id)
        覆盖:
        hasParameterMap 在类中 org.apache.ibatis.session.Configuration
      • getSqlFragments

        public java.util.Map<java.lang.String,​org.apache.ibatis.parsing.XNode> getSqlFragments()
        覆盖:
        getSqlFragments 在类中 org.apache.ibatis.session.Configuration
      • getMappedStatementNames

        public java.util.Collection<java.lang.String> getMappedStatementNames()
        覆盖:
        getMappedStatementNames 在类中 org.apache.ibatis.session.Configuration
      • getMappedStatements

        public java.util.Collection<org.apache.ibatis.mapping.MappedStatement> getMappedStatements()
        覆盖:
        getMappedStatements 在类中 org.apache.ibatis.session.Configuration
      • getMappedStatement

        public org.apache.ibatis.mapping.MappedStatement getMappedStatement​(java.lang.String id)
        覆盖:
        getMappedStatement 在类中 org.apache.ibatis.session.Configuration
      • getMappedStatement

        public org.apache.ibatis.mapping.MappedStatement getMappedStatement​(java.lang.String id,
                                                                            boolean validateIncompleteStatements)
        覆盖:
        getMappedStatement 在类中 org.apache.ibatis.session.Configuration
      • hasStatement

        public boolean hasStatement​(java.lang.String statementName,
                                    boolean validateIncompleteStatements)
        覆盖:
        hasStatement 在类中 org.apache.ibatis.session.Configuration
      • newExecutor

        public org.apache.ibatis.executor.Executor newExecutor​(org.apache.ibatis.transaction.Transaction transaction,
                                                               org.apache.ibatis.session.ExecutorType executorType)
        覆盖:
        newExecutor 在类中 org.apache.ibatis.session.Configuration
      • checkGloballyForDiscriminatedNestedResultMaps

        protected void checkGloballyForDiscriminatedNestedResultMaps​(org.apache.ibatis.mapping.ResultMap rm)
        覆盖:
        checkGloballyForDiscriminatedNestedResultMaps 在类中 org.apache.ibatis.session.Configuration
      • checkLocallyForDiscriminatedNestedResultMaps

        protected void checkLocallyForDiscriminatedNestedResultMaps​(org.apache.ibatis.mapping.ResultMap rm)
        覆盖:
        checkLocallyForDiscriminatedNestedResultMaps 在类中 org.apache.ibatis.session.Configuration
      • setUseGeneratedShortKey

        public void setUseGeneratedShortKey​(boolean useGeneratedShortKey)
        是否生成短key缓存
        从以下版本开始:
        3.4.0
      • isUseGeneratedShortKey

        public boolean isUseGeneratedShortKey()
        是否生成短key缓存
        从以下版本开始:
        3.4.0