Browse Source

部分代码优化

Caratacus 8 years ago
parent
commit
ad4d85d7d5

+ 0 - 4
mybatis-plus/src/main/java/com/baomidou/mybatisplus/MybatisConfiguration.java

@@ -72,10 +72,6 @@ public class MybatisConfiguration extends Configuration {
 	 * 是否刷新mapper
 	 */
 	public static boolean IS_REFRESH = false;
-	/**
-	 * 缓存注册标识
-	 */
-	public static Set<String> MAPPER_REGISTRY_CACHE = new ConcurrentSkipListSet<String>();
 
 	/**
 	 * 初始化调用

+ 5 - 3
mybatis-plus/src/main/java/com/baomidou/mybatisplus/MybatisPlusMapperBuilder.java

@@ -89,7 +89,7 @@ import org.apache.ibatis.type.JdbcType;
 import org.apache.ibatis.type.TypeHandler;
 import org.apache.ibatis.type.UnknownTypeHandler;
 
-import com.baomidou.mybatisplus.MybatisConfiguration;
+import com.baomidou.mybatisplus.mapper.BaseMapper;
 
 /**
  * 继承 MapperAnnotationBuilder 没有XML配置文件注入基础CRUD方法
@@ -133,8 +133,10 @@ public class MybatisPlusMapperBuilder extends MapperAnnotationBuilder {
 			parseCache();
 			parseCacheRef();
 			Method[] methods = type.getMethods();
-			// 注入增删改查方法
-			MybatisConfiguration.SQL_INJECTOR.inspectInject(configuration, assistant, type);
+			// TODO 注入 CURD 动态 SQL
+			if (BaseMapper.class.isAssignableFrom(type)) {
+				MybatisConfiguration.SQL_INJECTOR.inject(configuration, assistant, type);
+			}
 			for (Method method : methods) {
 				try {
 					// issue #237

+ 3 - 2
mybatis-plus/src/main/java/com/baomidou/mybatisplus/MybatisXMLConfigBuilder.java

@@ -23,6 +23,7 @@ import javax.sql.DataSource;
 
 import org.apache.ibatis.builder.BaseBuilder;
 import org.apache.ibatis.builder.BuilderException;
+import org.apache.ibatis.builder.xml.XMLMapperBuilder;
 import org.apache.ibatis.builder.xml.XMLMapperEntityResolver;
 import org.apache.ibatis.datasource.DataSourceFactory;
 import org.apache.ibatis.executor.ErrorContext;
@@ -378,14 +379,14 @@ public class MybatisXMLConfigBuilder extends BaseBuilder {
 						ErrorContext.instance().resource(resource);
 						InputStream inputStream = Resources.getResourceAsStream(resource);
 						//TODO
-						MybatisXMLMapperBuilder mapperParser = new MybatisXMLMapperBuilder(inputStream, configuration, resource,
+						XMLMapperBuilder mapperParser = new XMLMapperBuilder(inputStream, configuration, resource,
 								configuration.getSqlFragments());
 						mapperParser.parse();
 					} else if (resource == null && url != null && mapperClass == null) {
 						ErrorContext.instance().resource(url);
 						InputStream inputStream = Resources.getUrlAsStream(url);
 						//TODO
-						MybatisXMLMapperBuilder mapperParser = new MybatisXMLMapperBuilder(inputStream, configuration, url,
+						XMLMapperBuilder mapperParser = new XMLMapperBuilder(inputStream, configuration, url,
 								configuration.getSqlFragments());
 						mapperParser.parse();
 					} else if (resource == null && url == null && mapperClass != null) {

+ 0 - 448
mybatis-plus/src/main/java/com/baomidou/mybatisplus/MybatisXMLMapperBuilder.java

@@ -1,448 +0,0 @@
-/**
- * Copyright (c) 2011-2014, hubin (jobob@qq.com).
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus;
-
-import java.io.InputStream;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.ibatis.builder.BaseBuilder;
-import org.apache.ibatis.builder.BuilderException;
-import org.apache.ibatis.builder.CacheRefResolver;
-import org.apache.ibatis.builder.IncompleteElementException;
-import org.apache.ibatis.builder.MapperBuilderAssistant;
-import org.apache.ibatis.builder.ResultMapResolver;
-import org.apache.ibatis.builder.xml.XMLMapperEntityResolver;
-import org.apache.ibatis.builder.xml.XMLStatementBuilder;
-import org.apache.ibatis.cache.Cache;
-import org.apache.ibatis.executor.ErrorContext;
-import org.apache.ibatis.io.Resources;
-import org.apache.ibatis.mapping.Discriminator;
-import org.apache.ibatis.mapping.ParameterMapping;
-import org.apache.ibatis.mapping.ParameterMode;
-import org.apache.ibatis.mapping.ResultFlag;
-import org.apache.ibatis.mapping.ResultMap;
-import org.apache.ibatis.mapping.ResultMapping;
-import org.apache.ibatis.parsing.XNode;
-import org.apache.ibatis.parsing.XPathParser;
-import org.apache.ibatis.session.Configuration;
-import org.apache.ibatis.type.JdbcType;
-import org.apache.ibatis.type.TypeHandler;
-
-import com.baomidou.mybatisplus.mapper.BaseMapper;
-
-/**
- * <p>
- * org.apache.ibatis.builder.xml.XMLMapperBuilder
- * </p>
- * <p>
- * injector curdSql
- * </p>
- * 
- * @author Clinton Begin hubin
- * @Date 2016-06-13
- */
-public class MybatisXMLMapperBuilder extends BaseBuilder {
-
-	private XPathParser parser;
-	private MapperBuilderAssistant builderAssistant;
-	private Map<String, XNode> sqlFragments;
-	private String resource;
-
-	@Deprecated
-	public MybatisXMLMapperBuilder(Reader reader, Configuration configuration, String resource,
-			Map<String, XNode> sqlFragments, String namespace) {
-		this(reader, configuration, resource, sqlFragments);
-		this.builderAssistant.setCurrentNamespace(namespace);
-	}
-
-	@Deprecated
-	public MybatisXMLMapperBuilder(Reader reader, Configuration configuration, String resource,
-			Map<String, XNode> sqlFragments) {
-		this(new XPathParser(reader, true, configuration.getVariables(), new XMLMapperEntityResolver()), configuration,
-				resource, sqlFragments);
-	}
-
-	public MybatisXMLMapperBuilder(InputStream inputStream, Configuration configuration, String resource,
-			Map<String, XNode> sqlFragments, String namespace) {
-		this(inputStream, configuration, resource, sqlFragments);
-		this.builderAssistant.setCurrentNamespace(namespace);
-	}
-
-	public MybatisXMLMapperBuilder(InputStream inputStream, Configuration configuration, String resource,
-			Map<String, XNode> sqlFragments) {
-		this(new XPathParser(inputStream, true, configuration.getVariables(), new XMLMapperEntityResolver()),
-				configuration, resource, sqlFragments);
-	}
-
-	private MybatisXMLMapperBuilder(XPathParser parser, Configuration configuration, String resource,
-			Map<String, XNode> sqlFragments) {
-		super(configuration);
-		this.builderAssistant = new MapperBuilderAssistant(configuration, resource);
-		this.parser = parser;
-		this.sqlFragments = sqlFragments;
-		this.resource = resource;
-	}
-
-	public void parse() {
-		if (!configuration.isResourceLoaded(resource)) {
-			configurationElement(parser.evalNode("/mapper"));
-			configuration.addLoadedResource(resource);
-			bindMapperForNamespace();
-		}
-
-		parsePendingResultMaps();
-		parsePendingChacheRefs();
-		parsePendingStatements();
-	}
-
-	public XNode getSqlFragment(String refid) {
-		return sqlFragments.get(refid);
-	}
-
-	private void configurationElement(XNode context) {
-		try {
-			String namespace = context.getStringAttribute("namespace");
-			if (namespace == null || namespace.equals("")) {
-				throw new BuilderException("Mapper's namespace cannot be empty");
-			}
-			builderAssistant.setCurrentNamespace(namespace);
-			cacheRefElement(context.evalNode("cache-ref"));
-			cacheElement(context.evalNode("cache"));
-			parameterMapElement(context.evalNodes("/mapper/parameterMap"));
-			resultMapElements(context.evalNodes("/mapper/resultMap"));
-			sqlElement(context.evalNodes("/mapper/sql"));
-			buildStatementFromContext(context.evalNodes("select|insert|update|delete"));
-		} catch (Exception e) {
-			throw new BuilderException("Error parsing Mapper XML. Cause: " + e, e);
-		}
-	}
-
-	private void buildStatementFromContext(List<XNode> list) {
-		if (configuration.getDatabaseId() != null) {
-			buildStatementFromContext(list, configuration.getDatabaseId());
-		}
-		buildStatementFromContext(list, null);
-	}
-
-	private void buildStatementFromContext(List<XNode> list, String requiredDatabaseId) {
-		for (XNode context : list) {
-			final XMLStatementBuilder statementParser = new XMLStatementBuilder(configuration, builderAssistant,
-					context, requiredDatabaseId);
-			try {
-				statementParser.parseStatementNode();
-			} catch (IncompleteElementException e) {
-				configuration.addIncompleteStatement(statementParser);
-			}
-		}
-	}
-
-	private void parsePendingResultMaps() {
-		Collection<ResultMapResolver> incompleteResultMaps = configuration.getIncompleteResultMaps();
-		synchronized (incompleteResultMaps) {
-			Iterator<ResultMapResolver> iter = incompleteResultMaps.iterator();
-			while (iter.hasNext()) {
-				try {
-					iter.next().resolve();
-					iter.remove();
-				} catch (IncompleteElementException e) {
-					// ResultMap is still missing a resource...
-				}
-			}
-		}
-	}
-
-	private void parsePendingChacheRefs() {
-		Collection<CacheRefResolver> incompleteCacheRefs = configuration.getIncompleteCacheRefs();
-		synchronized (incompleteCacheRefs) {
-			Iterator<CacheRefResolver> iter = incompleteCacheRefs.iterator();
-			while (iter.hasNext()) {
-				try {
-					iter.next().resolveCacheRef();
-					iter.remove();
-				} catch (IncompleteElementException e) {
-					// Cache ref is still missing a resource...
-				}
-			}
-		}
-	}
-
-	private void parsePendingStatements() {
-		Collection<XMLStatementBuilder> incompleteStatements = configuration.getIncompleteStatements();
-		synchronized (incompleteStatements) {
-			Iterator<XMLStatementBuilder> iter = incompleteStatements.iterator();
-			while (iter.hasNext()) {
-				try {
-					iter.next().parseStatementNode();
-					iter.remove();
-				} catch (IncompleteElementException e) {
-					// Statement is still missing a resource...
-				}
-			}
-		}
-	}
-
-	private void cacheRefElement(XNode context) {
-		if (context != null) {
-			configuration.addCacheRef(builderAssistant.getCurrentNamespace(), context.getStringAttribute("namespace"));
-			CacheRefResolver cacheRefResolver = new CacheRefResolver(builderAssistant,
-					context.getStringAttribute("namespace"));
-			try {
-				cacheRefResolver.resolveCacheRef();
-			} catch (IncompleteElementException e) {
-				configuration.addIncompleteCacheRef(cacheRefResolver);
-			}
-		}
-	}
-
-	private void cacheElement(XNode context) throws Exception {
-		if (context != null) {
-			String type = context.getStringAttribute("type", "PERPETUAL");
-			Class<? extends Cache> typeClass = typeAliasRegistry.resolveAlias(type);
-			String eviction = context.getStringAttribute("eviction", "LRU");
-			Class<? extends Cache> evictionClass = typeAliasRegistry.resolveAlias(eviction);
-			Long flushInterval = context.getLongAttribute("flushInterval");
-			Integer size = context.getIntAttribute("size");
-			boolean readWrite = !context.getBooleanAttribute("readOnly", false);
-			boolean blocking = context.getBooleanAttribute("blocking", false);
-			Properties props = context.getChildrenAsProperties();
-			builderAssistant.useNewCache(typeClass, evictionClass, flushInterval, size, readWrite, blocking, props);
-		}
-	}
-
-	private void parameterMapElement(List<XNode> list) throws Exception {
-		for (XNode parameterMapNode : list) {
-			String id = parameterMapNode.getStringAttribute("id");
-			String type = parameterMapNode.getStringAttribute("type");
-			Class<?> parameterClass = resolveClass(type);
-			List<XNode> parameterNodes = parameterMapNode.evalNodes("parameter");
-			List<ParameterMapping> parameterMappings = new ArrayList<ParameterMapping>();
-			for (XNode parameterNode : parameterNodes) {
-				String property = parameterNode.getStringAttribute("property");
-				String javaType = parameterNode.getStringAttribute("javaType");
-				String jdbcType = parameterNode.getStringAttribute("jdbcType");
-				String resultMap = parameterNode.getStringAttribute("resultMap");
-				String mode = parameterNode.getStringAttribute("mode");
-				String typeHandler = parameterNode.getStringAttribute("typeHandler");
-				Integer numericScale = parameterNode.getIntAttribute("numericScale");
-				ParameterMode modeEnum = resolveParameterMode(mode);
-				Class<?> javaTypeClass = resolveClass(javaType);
-				JdbcType jdbcTypeEnum = resolveJdbcType(jdbcType);
-				@SuppressWarnings("unchecked")
-				Class<? extends TypeHandler<?>> typeHandlerClass = (Class<? extends TypeHandler<?>>) resolveClass(
-						typeHandler);
-				ParameterMapping parameterMapping = builderAssistant.buildParameterMapping(parameterClass, property,
-						javaTypeClass, jdbcTypeEnum, resultMap, modeEnum, typeHandlerClass, numericScale);
-				parameterMappings.add(parameterMapping);
-			}
-			builderAssistant.addParameterMap(id, parameterClass, parameterMappings);
-		}
-	}
-
-	private void resultMapElements(List<XNode> list) throws Exception {
-		for (XNode resultMapNode : list) {
-			try {
-				resultMapElement(resultMapNode);
-			} catch (IncompleteElementException e) {
-				// ignore, it will be retried
-			}
-		}
-	}
-
-	private ResultMap resultMapElement(XNode resultMapNode) throws Exception {
-		return resultMapElement(resultMapNode, Collections.<ResultMapping> emptyList());
-	}
-
-	private ResultMap resultMapElement(XNode resultMapNode, List<ResultMapping> additionalResultMappings)
-			throws Exception {
-		ErrorContext.instance().activity("processing " + resultMapNode.getValueBasedIdentifier());
-		String id = resultMapNode.getStringAttribute("id", resultMapNode.getValueBasedIdentifier());
-		String type = resultMapNode.getStringAttribute("type", resultMapNode.getStringAttribute("ofType",
-				resultMapNode.getStringAttribute("resultType", resultMapNode.getStringAttribute("javaType"))));
-		String extend = resultMapNode.getStringAttribute("extends");
-		Boolean autoMapping = resultMapNode.getBooleanAttribute("autoMapping");
-		Class<?> typeClass = resolveClass(type);
-		Discriminator discriminator = null;
-		List<ResultMapping> resultMappings = new ArrayList<ResultMapping>();
-		resultMappings.addAll(additionalResultMappings);
-		List<XNode> resultChildren = resultMapNode.getChildren();
-		for (XNode resultChild : resultChildren) {
-			if ("constructor".equals(resultChild.getName())) {
-				processConstructorElement(resultChild, typeClass, resultMappings);
-			} else if ("discriminator".equals(resultChild.getName())) {
-				discriminator = processDiscriminatorElement(resultChild, typeClass, resultMappings);
-			} else {
-				List<ResultFlag> flags = new ArrayList<ResultFlag>();
-				if ("id".equals(resultChild.getName())) {
-					flags.add(ResultFlag.ID);
-				}
-				resultMappings.add(buildResultMappingFromContext(resultChild, typeClass, flags));
-			}
-		}
-		ResultMapResolver resultMapResolver = new ResultMapResolver(builderAssistant, id, typeClass, extend,
-				discriminator, resultMappings, autoMapping);
-		try {
-			return resultMapResolver.resolve();
-		} catch (IncompleteElementException e) {
-			configuration.addIncompleteResultMap(resultMapResolver);
-			throw e;
-		}
-	}
-
-	private void processConstructorElement(XNode resultChild, Class<?> resultType, List<ResultMapping> resultMappings)
-			throws Exception {
-		List<XNode> argChildren = resultChild.getChildren();
-		for (XNode argChild : argChildren) {
-			List<ResultFlag> flags = new ArrayList<ResultFlag>();
-			flags.add(ResultFlag.CONSTRUCTOR);
-			if ("idArg".equals(argChild.getName())) {
-				flags.add(ResultFlag.ID);
-			}
-			resultMappings.add(buildResultMappingFromContext(argChild, resultType, flags));
-		}
-	}
-
-	private Discriminator processDiscriminatorElement(XNode context, Class<?> resultType,
-			List<ResultMapping> resultMappings) throws Exception {
-		String column = context.getStringAttribute("column");
-		String javaType = context.getStringAttribute("javaType");
-		String jdbcType = context.getStringAttribute("jdbcType");
-		String typeHandler = context.getStringAttribute("typeHandler");
-		Class<?> javaTypeClass = resolveClass(javaType);
-		@SuppressWarnings("unchecked")
-		Class<? extends TypeHandler<?>> typeHandlerClass = (Class<? extends TypeHandler<?>>) resolveClass(typeHandler);
-		JdbcType jdbcTypeEnum = resolveJdbcType(jdbcType);
-		Map<String, String> discriminatorMap = new HashMap<String, String>();
-		for (XNode caseChild : context.getChildren()) {
-			String value = caseChild.getStringAttribute("value");
-			String resultMap = caseChild.getStringAttribute("resultMap",
-					processNestedResultMappings(caseChild, resultMappings));
-			discriminatorMap.put(value, resultMap);
-		}
-		return builderAssistant.buildDiscriminator(resultType, column, javaTypeClass, jdbcTypeEnum, typeHandlerClass,
-				discriminatorMap);
-	}
-
-	private void sqlElement(List<XNode> list) throws Exception {
-		if (configuration.getDatabaseId() != null) {
-			sqlElement(list, configuration.getDatabaseId());
-		}
-		sqlElement(list, null);
-	}
-
-	private void sqlElement(List<XNode> list, String requiredDatabaseId) throws Exception {
-		for (XNode context : list) {
-			String databaseId = context.getStringAttribute("databaseId");
-			String id = context.getStringAttribute("id");
-			id = builderAssistant.applyCurrentNamespace(id, false);
-			if (databaseIdMatchesCurrent(id, databaseId, requiredDatabaseId)) {
-				sqlFragments.put(id, context);
-			}
-		}
-	}
-
-	private boolean databaseIdMatchesCurrent(String id, String databaseId, String requiredDatabaseId) {
-		if (requiredDatabaseId != null) {
-			if (!requiredDatabaseId.equals(databaseId)) {
-				return false;
-			}
-		} else {
-			if (databaseId != null) {
-				return false;
-			}
-			// skip this fragment if there is a previous one with a not null
-			// databaseId
-			if (this.sqlFragments.containsKey(id)) {
-				XNode context = this.sqlFragments.get(id);
-				if (context.getStringAttribute("databaseId") != null) {
-					return false;
-				}
-			}
-		}
-		return true;
-	}
-
-	private ResultMapping buildResultMappingFromContext(XNode context, Class<?> resultType, List<ResultFlag> flags)
-			throws Exception {
-		String property = context.getStringAttribute("property");
-		String column = context.getStringAttribute("column");
-		String javaType = context.getStringAttribute("javaType");
-		String jdbcType = context.getStringAttribute("jdbcType");
-		String nestedSelect = context.getStringAttribute("select");
-		String nestedResultMap = context.getStringAttribute("resultMap",
-				processNestedResultMappings(context, Collections.<ResultMapping> emptyList()));
-		String notNullColumn = context.getStringAttribute("notNullColumn");
-		String columnPrefix = context.getStringAttribute("columnPrefix");
-		String typeHandler = context.getStringAttribute("typeHandler");
-		String resultSet = context.getStringAttribute("resultSet");
-		String foreignColumn = context.getStringAttribute("foreignColumn");
-		boolean lazy = "lazy".equals(
-				context.getStringAttribute("fetchType", configuration.isLazyLoadingEnabled() ? "lazy" : "eager"));
-		Class<?> javaTypeClass = resolveClass(javaType);
-		@SuppressWarnings("unchecked")
-		Class<? extends TypeHandler<?>> typeHandlerClass = (Class<? extends TypeHandler<?>>) resolveClass(typeHandler);
-		JdbcType jdbcTypeEnum = resolveJdbcType(jdbcType);
-		return builderAssistant.buildResultMapping(resultType, property, column, javaTypeClass, jdbcTypeEnum,
-				nestedSelect, nestedResultMap, notNullColumn, columnPrefix, typeHandlerClass, flags, resultSet,
-				foreignColumn, lazy);
-	}
-
-	private String processNestedResultMappings(XNode context, List<ResultMapping> resultMappings) throws Exception {
-		if ("association".equals(context.getName()) || "collection".equals(context.getName())
-				|| "case".equals(context.getName())) {
-			if (context.getStringAttribute("select") == null) {
-				ResultMap resultMap = resultMapElement(context, resultMappings);
-				return resultMap.getId();
-			}
-		}
-		return null;
-	}
-
-	private void bindMapperForNamespace() {
-		String namespace = builderAssistant.getCurrentNamespace();
-		if (namespace != null) {
-			Class<?> boundType = null;
-			try {
-				boundType = Resources.classForName(namespace);
-			} catch (ClassNotFoundException e) {
-				// ignore, bound type is not required
-			}
-			if (boundType != null) {
-				if (!configuration.hasMapper(boundType)) {
-					// Spring may not know the real resource name so we set a
-					// flag
-					// to prevent loading again this resource from the mapper
-					// interface
-					// look at MapperAnnotationBuilder#loadXmlResource
-					configuration.addLoadedResource("namespace:" + namespace);
-					configuration.addMapper(boundType);
-				}
-				//TODO 注入 CURD 动态 SQL
-				if (BaseMapper.class.isAssignableFrom(boundType)) {
-					MybatisConfiguration.SQL_INJECTOR.inspectInject(configuration, builderAssistant, boundType);
-				}
-			}
-		}
-	}
-
-}

+ 0 - 16
mybatis-plus/src/main/java/com/baomidou/mybatisplus/mapper/AutoSqlInjector.java

@@ -60,22 +60,6 @@ public class AutoSqlInjector implements ISqlInjector {
 
 	protected DBType dbType = DBType.MYSQL;
 
-	/**
-	 * CRUD注入后给予标识 注入过后不再注入
-	 * 
-	 * @param configuration
-	 * @param builderAssistant
-	 * @param mapperClass
-	 */
-	public void inspectInject(Configuration configuration, MapperBuilderAssistant builderAssistant, Class<?> mapperClass) {
-		String className = mapperClass.toString();
-		Set<String> mapperRegistryCache = MybatisConfiguration.MAPPER_REGISTRY_CACHE;
-		if (!mapperRegistryCache.contains(className)) {
-			inject(configuration, builderAssistant, mapperClass);
-			mapperRegistryCache.add(className);
-		}
-	}
-
 	/**
 	 * 注入单点 crudSql
 	 */

+ 0 - 10
mybatis-plus/src/main/java/com/baomidou/mybatisplus/mapper/ISqlInjector.java

@@ -35,14 +35,4 @@ public interface ISqlInjector {
 	 */
 	void inject(Configuration configuration, MapperBuilderAssistant builderAssistant, Class<?> mapperClass);
 
-	/**
-	 * <p>
-	 * 检查SQL是否已经注入
-	 * </p>
-	 * <p>
-	 * ps:注入基本SQL后给予标识 注入过不再注入
-	 * </p>
-	 */
-	void inspectInject(Configuration configuration, MapperBuilderAssistant builderAssistant, Class<?> mapperClass);
-
 }

+ 11 - 16
mybatis-plus/src/main/java/com/baomidou/mybatisplus/spring/MybatisSqlSessionFactoryBean.java

@@ -27,6 +27,8 @@ import java.util.Properties;
 
 import javax.sql.DataSource;
 
+import org.apache.ibatis.builder.xml.XMLConfigBuilder;
+import org.apache.ibatis.builder.xml.XMLMapperBuilder;
 import org.apache.ibatis.cache.Cache;
 import org.apache.ibatis.executor.ErrorContext;
 import org.apache.ibatis.io.VFS;
@@ -55,7 +57,6 @@ import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy;
 
 import com.baomidou.mybatisplus.MybatisConfiguration;
 import com.baomidou.mybatisplus.MybatisXMLConfigBuilder;
-import com.baomidou.mybatisplus.MybatisXMLMapperBuilder;
 import com.baomidou.mybatisplus.exceptions.MybatisPlusException;
 import com.baomidou.mybatisplus.mapper.DBType;
 import com.baomidou.mybatisplus.mapper.IMetaObjectHandler;
@@ -67,7 +68,7 @@ import com.baomidou.mybatisplus.toolkit.PackageHelper;
  * 拷贝类 org.mybatis.spring.SqlSessionFactoryBean 修改方法 buildSqlSessionFactory()
  * 加载自定义 MybatisXmlConfigBuilder
  * </p>
- * 
+ *
  * @author hubin
  * @Date 2016-01-23
  */
@@ -300,7 +301,7 @@ public class MybatisSqlSessionFactoryBean
 
 	/**
 	 * Set a customized MyBatis configuration.
-	 * 
+	 *
 	 * @param configuration
 	 *            MyBatis configuration
 	 * @since 1.3.0
@@ -439,8 +440,7 @@ public class MybatisSqlSessionFactoryBean
 
 		Configuration configuration;
 
-		// TODO 加载自定义 MybatisXmlConfigBuilder
-		MybatisXMLConfigBuilder xmlConfigBuilder = null;
+		XMLConfigBuilder xmlConfigBuilder = null;
 		if (this.configuration != null) {
 			configuration = this.configuration;
 			if (configuration.getVariables() == null) {
@@ -449,13 +449,11 @@ public class MybatisSqlSessionFactoryBean
 				configuration.getVariables().putAll(this.configurationProperties);
 			}
 		} else if (this.configLocation != null) {
-			xmlConfigBuilder = new MybatisXMLConfigBuilder(this.configLocation.getInputStream(), null,
-					this.configurationProperties);
+			xmlConfigBuilder = new XMLConfigBuilder(this.configLocation.getInputStream(), null, this.configurationProperties);
 			configuration = xmlConfigBuilder.getConfiguration();
 		} else {
 			if (LOGGER.isDebugEnabled()) {
-				LOGGER.debug(
-						"Property `configuration` or 'configLocation' not specified, using default MyBatis Configuration");
+				LOGGER.debug("Property `configuration` or 'configLocation' not specified, using default MyBatis Configuration");
 			}
 			// TODO 使用自定义配置
 			configuration = new MybatisConfiguration();
@@ -533,8 +531,7 @@ public class MybatisSqlSessionFactoryBean
 			}
 		}
 
-		if (this.databaseIdProvider != null) {// fix #64 set databaseId before
-												// parse mapper xmls
+		if (this.databaseIdProvider != null) {//fix #64 set databaseId before parse mapper xmls
 			try {
 				configuration.setDatabaseId(this.databaseIdProvider.getDatabaseId(this.dataSource));
 			} catch (SQLException e) {
@@ -573,10 +570,8 @@ public class MybatisSqlSessionFactoryBean
 				}
 
 				try {
-					// TODO
-					MybatisXMLMapperBuilder xmlMapperBuilder = new MybatisXMLMapperBuilder(
-							mapperLocation.getInputStream(), configuration, mapperLocation.toString(),
-							configuration.getSqlFragments());
+					XMLMapperBuilder xmlMapperBuilder = new XMLMapperBuilder(mapperLocation.getInputStream(),
+							configuration, mapperLocation.toString(), configuration.getSqlFragments());
 					xmlMapperBuilder.parse();
 				} catch (Exception e) {
 					throw new NestedIOException("Failed to parse mapping resource: '" + mapperLocation + "'", e);
@@ -632,4 +627,4 @@ public class MybatisSqlSessionFactoryBean
 		}
 	}
 
-}
+}

+ 1 - 1
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/EntityWrapperTest.java

@@ -227,7 +227,7 @@ public class EntityWrapperTest {
 		ew.in("test_type", list);
 		String sqlPart = ew.getSqlSegment();
 		System.out.println("sql ==> " + sqlPart);
-		Assert.assertEquals("WHERE (test_type BETWEEN 11 AND 33)", sqlPart);
+		Assert.assertEquals("WHERE (test_type IN (111111111,222222222,333333333))", sqlPart);
 	}
 
 	/**