MyBatis-3.4.2-源码分析7:解析XML之settingsElement(settings)

接下来,就是配置项如何影响Configuration的值了。

---未完待续

private void settingsElement(Properties props) throws Exception {
		//设置autoMappingBehavior,默认为PARTIAL
		configuration.setAutoMappingBehavior(
				AutoMappingBehavior.valueOf(props.getProperty("autoMappingBehavior", "PARTIAL")));
		//设置autoMappingUnknownColumnBehavior,默认为NONE
		configuration.setAutoMappingUnknownColumnBehavior(AutoMappingUnknownColumnBehavior
				.valueOf(props.getProperty("autoMappingUnknownColumnBehavior", "NONE")));
		//设置cacheEnabled,默认为true
		configuration.setCacheEnabled(booleanValueOf(props.getProperty("cacheEnabled"), true));
		//设置proxyFactory为new JavassistProxyFactory()
		configuration.setProxyFactory((ProxyFactory) createInstance(props.getProperty("proxyFactory")));
		//设置lazyLoadingEnabled为false
		configuration.setLazyLoadingEnabled(booleanValueOf(props.getProperty("lazyLoadingEnabled"), false));
		//设置aggressiveLazyLoading为false
		configuration.setAggressiveLazyLoading(booleanValueOf(props.getProperty("aggressiveLazyLoading"), false));
		//设置multipleResultSetsEnabled为true
		configuration
				.setMultipleResultSetsEnabled(booleanValueOf(props.getProperty("multipleResultSetsEnabled"), true));
		//
		//
		//设置useColumnLabel为true
		configuration.setUseColumnLabel(booleanValueOf(props.getProperty("useColumnLabel"), true));
		//设置useGeneratedKeys为false
		configuration.setUseGeneratedKeys(booleanValueOf(props.getProperty("useGeneratedKeys"), false));
		//设置defaultExecutorType为SIMPLE
		configuration.setDefaultExecutorType(ExecutorType.valueOf(props.getProperty("defaultExecutorType", "SIMPLE")));
		//设置defaultStatementTimeout为null
		configuration.setDefaultStatementTimeout(integerValueOf(props.getProperty("defaultStatementTimeout"), null));
		//设置defaultFetchSize为null
		configuration.setDefaultFetchSize(integerValueOf(props.getProperty("defaultFetchSize"), null));
		//设置mapUnderscoreToCamelCase为false
		configuration.setMapUnderscoreToCamelCase(booleanValueOf(props.getProperty("mapUnderscoreToCamelCase"), false));
		//设置safeRowBoundsEnabled为false
		configuration.setSafeRowBoundsEnabled(booleanValueOf(props.getProperty("safeRowBoundsEnabled"), false));
		//设置localCacheScope为SESSION
		configuration.setLocalCacheScope(LocalCacheScope.valueOf(props.getProperty("localCacheScope", "SESSION")));
		//
		//设置jdbcTypeForNull为OTHER
		configuration.setJdbcTypeForNull(JdbcType.valueOf(props.getProperty("jdbcTypeForNull", "OTHER")));
		//设置lazyLoadTriggerMethods为4个函数
		configuration.setLazyLoadTriggerMethods(
				stringSetValueOf(props.getProperty("lazyLoadTriggerMethods"), "equals,clone,hashCode,toString"));
		//设置safeResultHandlerEnabled为true
		configuration.setSafeResultHandlerEnabled(booleanValueOf(props.getProperty("safeResultHandlerEnabled"), true));
		//
		//
		//设置defaultDriverClass为XmlLanguageDrier.class
		configuration.setDefaultScriptingLanguage(resolveClass(props.getProperty("defaultScriptingLanguage")));
		//
		//设置callSettersOnNulls为false
		configuration.setCallSettersOnNulls(booleanValueOf(props.getProperty("callSettersOnNulls"), false));
		//设置useActualParamName为true
		configuration.setUseActualParamName(booleanValueOf(props.getProperty("useActualParamName"), true));
		//设置returnInstanceForEmptyRow为false
		configuration
				.setReturnInstanceForEmptyRow(booleanValueOf(props.getProperty("returnInstanceForEmptyRow"), false));
		//设置logPrefix的值
		configuration.setLogPrefix(props.getProperty("logPrefix"));
		@SuppressWarnings("unchecked")
		//继续
		//
		//设置LogImpl,前提是非空
		Class<? extends Log> logImpl = (Class<? extends Log>) resolveClass(props.getProperty("logImpl"));
		configuration.setLogImpl(logImpl);
		//设置configurationFactory,默认为null
		configuration.setConfigurationFactory(resolveClass(props.getProperty("configurationFactory")));
		//结束
	}

 

转载于:https://my.oschina.net/qiangzigege/blog/868050

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值