Parcourir la source

Merge branch 'dev-2.0' into dev

Conflicts:
	mybatis-plus/src/main/java/com/baomidou/framework/service/IService.java
	mybatis-plus/src/main/java/com/baomidou/framework/service/impl/ServiceImpl.java
	mybatis-plus/src/main/java/com/baomidou/mybatisplus/mapper/AutoSqlInjector.java
	mybatis-plus/src/main/java/com/baomidou/mybatisplus/toolkit/StringEscape.java
	mybatis-plus/src/main/java/com/baomidou/mybatisplus/toolkit/StringUtils.java
	mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/EntityWrapperTest.java
Caratacus il y a 8 ans
Parent
commit
fecca2fadb
26 fichiers modifiés avec 685 ajouts et 537 suppressions
  1. 19 1
      mybatis-plus/pom.xml
  2. 39 34
      mybatis-plus/src/main/java/com/baomidou/framework/service/IService.java
  3. 229 212
      mybatis-plus/src/main/java/com/baomidou/framework/service/impl/ServiceImpl.java
  4. 10 0
      mybatis-plus/src/main/java/com/baomidou/mybatisplus/MybatisConfiguration.java
  5. 7 5
      mybatis-plus/src/main/java/com/baomidou/mybatisplus/MybatisMapperRegistry.java
  6. 8 9
      mybatis-plus/src/main/java/com/baomidou/mybatisplus/MybatisSessionFactoryBuilder.java
  7. 1 2
      mybatis-plus/src/main/java/com/baomidou/mybatisplus/MybatisXMLMapperBuilder.java
  8. 8 8
      mybatis-plus/src/main/java/com/baomidou/mybatisplus/generator/AutoGenerator.java
  9. 2 10
      mybatis-plus/src/main/java/com/baomidou/mybatisplus/generator/ConfigGenerator.java
  10. 25 25
      mybatis-plus/src/main/java/com/baomidou/mybatisplus/mapper/AutoSqlInjector.java
  11. 1 1
      mybatis-plus/src/main/java/com/baomidou/mybatisplus/mapper/BaseMapper.java
  12. 10 9
      mybatis-plus/src/main/java/com/baomidou/mybatisplus/mapper/ISqlInjector.java
  13. 10 10
      mybatis-plus/src/main/java/com/baomidou/mybatisplus/spring/MybatisSqlSessionFactoryBean.java
  14. 35 0
      mybatis-plus/src/main/java/com/baomidou/mybatisplus/toolkit/ReflectionKit.java
  15. 3 3
      mybatis-plus/src/main/java/com/baomidou/mybatisplus/toolkit/Sequence.java
  16. 68 26
      mybatis-plus/src/main/java/com/baomidou/mybatisplus/toolkit/StringEscape.java
  17. 14 3
      mybatis-plus/src/main/java/com/baomidou/mybatisplus/toolkit/TableInfo.java
  18. 161 142
      mybatis-plus/src/main/java/com/baomidou/mybatisplus/toolkit/TableInfoHelper.java
  19. 2 2
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/RoleMapper.java
  20. 3 3
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/TestMapper.java
  21. 5 6
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/UserMapper.java
  22. 11 12
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/UserMapperTest.java
  23. 4 3
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/entity/Test.java
  24. 2 2
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/oracle/TestUserMapper.java
  25. 7 8
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/oracle/TestUserMapperTest.java
  26. 1 1
      mybatis-plus/src/test/resources/mysql-config.xml

+ 19 - 1
mybatis-plus/pom.xml

@@ -3,7 +3,7 @@
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>com.baomidou</groupId>
 	<artifactId>mybatis-plus</artifactId>
-	<version>1.4.8</version>
+	<version>2.0</version>
 	<packaging>jar</packaging>
 
 	<name>mybatis-plus</name>
@@ -125,6 +125,24 @@
 			<version>${contiperf.version}</version>
 			<scope>test</scope>
 		</dependency>
+		<dependency>
+			<groupId>org.xerial</groupId>
+			<artifactId>sqlite-jdbc</artifactId>
+			<version>3.14.2.1</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>postgresql</groupId>
+			<artifactId>postgresql</artifactId>
+			<version>9.1-901-1.jdbc4</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.hsqldb</groupId>
+			<artifactId>hsqldb</artifactId>
+			<version>2.3.4</version>
+			<scope>test</scope>
+		</dependency>
 		<!-- test end -->
 	</dependencies>
 

+ 39 - 34
mybatis-plus/src/main/java/com/baomidou/framework/service/IService.java

@@ -22,23 +22,21 @@ import java.io.Serializable;
 import java.util.List;
 import java.util.Map;
 
-import org.springframework.jdbc.datasource.DataSourceTransactionManager;
-
 /**
  * <p>
  * 顶级 Service
  * </p>
- * 
+ *
  * @author hubin
  * @Date 2016-04-20
  */
-public interface IService<T, PK> {
+public interface IService<T> {
 
 	/**
 	 * <p>
 	 * 插入一条记录
 	 * </p>
-	 * 
+	 *
 	 * @param entity
 	 *            实体对象
 	 * @return boolean
@@ -49,7 +47,7 @@ public interface IService<T, PK> {
 	 * <p>
 	 * 插入一条记录(选择字段, null 字段不插入)
 	 * </p>
-	 * 
+	 *
 	 * @param entity
 	 *            实体对象
 	 * @return boolean
@@ -60,7 +58,7 @@ public interface IService<T, PK> {
 	 * <p>
 	 * 插入(批量),该方法不适合 Oracle
 	 * </p>
-	 * 
+	 *
 	 * @param entityList
 	 *            实体对象列表
 	 * @return boolean
@@ -69,28 +67,35 @@ public interface IService<T, PK> {
 
 	/**
 	 * <p>
-	 * 插入(批量)( batchSize 批次提交
+	 * 插入(批量)(选择字段, null 字段不插入
 	 * </p>
-	 * 
-	 * @param txManager
-	 *            数据源事务管理器
+	 *
 	 * @param entityList
 	 *            实体对象列表
 	 * @param batchSize
-	 *            批次数量
-	 * @return boolean 
-	 * <bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate" >
-	 *     <constructor-arg index="0" ref="sqlSessionFactory"/>
-	 *     <constructor-arg index="1" value="BATCH"/>
-	 * </bean>
+	 *
+	 * @return boolean
+	 */
+	boolean insertBatchSelective(List<T> entityList, int batchSize);
+
+	/**
+	 * <p>
+	 * 插入(批量)
+	 * </p>
+	 *
+	 * @param entityList
+	 *            实体对象列表
+	 * @param entityList
+	 *
+	 * @return boolean
 	 */
-	boolean insertBatch(DataSourceTransactionManager txManager, List<T> entityList, int batchSize);
+	boolean insertBatch(List<T> entityList, int batchSize);
 
 	/**
 	 * <p>
 	 * 插入(批量)(选择字段, null 字段不插入)
 	 * </p>
-	 * 
+	 *
 	 * @param entityList
 	 *            实体对象列表
 	 * @return boolean
@@ -101,7 +106,7 @@ public interface IService<T, PK> {
 	 * <p>
 	 * 根据 ID 删除
 	 * </p>
-	 * 
+	 *
 	 * @param id
 	 *            主键ID
 	 * @return boolean
@@ -112,7 +117,7 @@ public interface IService<T, PK> {
 	 * <p>
 	 * 根据 columnMap 条件,删除记录
 	 * </p>
-	 * 
+	 *
 	 * @param columnMap
 	 *            表字段 map 对象
 	 * @return boolean
@@ -123,7 +128,7 @@ public interface IService<T, PK> {
 	 * <p>
 	 * 根据 entity 条件,删除记录
 	 * </p>
-	 * 
+	 *
 	 * @param entity
 	 *            实体对象
 	 * @return boolean
@@ -134,7 +139,7 @@ public interface IService<T, PK> {
 	 * <p>
 	 * 删除(根据ID 批量删除)
 	 * </p>
-	 * 
+	 *
 	 * @param idList
 	 *            主键ID列表
 	 * @return boolean
@@ -145,7 +150,7 @@ public interface IService<T, PK> {
 	 * <p>
 	 * 根据 ID 修改
 	 * </p>
-	 * 
+	 *
 	 * @param entity
 	 *            实体对象
 	 * @return boolean
@@ -156,7 +161,7 @@ public interface IService<T, PK> {
 	 * <p>
 	 * 根据 ID 选择修改
 	 * </p>
-	 * 
+	 *
 	 * @param entity
 	 *            实体对象
 	 * @return boolean
@@ -167,7 +172,7 @@ public interface IService<T, PK> {
 	 * <p>
 	 * 根据 whereEntity 条件,更新记录
 	 * </p>
-	 * 
+	 *
 	 * @param entity
 	 *            实体对象
 	 * @param whereEntity
@@ -180,7 +185,7 @@ public interface IService<T, PK> {
 	 * <p>
 	 * 根据 whereEntity 条件,选择更新记录
 	 * </p>
-	 * 
+	 *
 	 * @param entity
 	 *            实体对象
 	 * @param whereEntity
@@ -193,7 +198,7 @@ public interface IService<T, PK> {
 	 * <p>
 	 * 根据ID 批量更新
 	 * </p>
-	 * 
+	 *
 	 * @param entityList
 	 *            实体对象列表
 	 * @return boolean
@@ -226,7 +231,7 @@ public interface IService<T, PK> {
 	 * <p>
 	 * 根据 ID 查询
 	 * </p>
-	 * 
+	 *
 	 * @param id
 	 *            主键ID
 	 * @return T
@@ -237,7 +242,7 @@ public interface IService<T, PK> {
 	 * <p>
 	 * 查询(根据ID 批量查询)
 	 * </p>
-	 * 
+	 *
 	 * @param idList
 	 *            主键ID列表
 	 * @return List<T>
@@ -248,7 +253,7 @@ public interface IService<T, PK> {
 	 * <p>
 	 * 查询(根据 columnMap 条件)
 	 * </p>
-	 * 
+	 *
 	 * @param columnMap
 	 *            表字段 map 对象
 	 * @return List<T>
@@ -259,7 +264,7 @@ public interface IService<T, PK> {
 	 * <p>
 	 * 根据 entity 条件,查询一条记录
 	 * </p>
-	 * 
+	 *
 	 * @param entity
 	 *            实体对象
 	 * @return T
@@ -281,7 +286,7 @@ public interface IService<T, PK> {
 	 * <p>
 	 * 根据 entity 条件,查询总记录数
 	 * </p>
-	 * 
+	 *
 	 * @param entity
 	 *            实体对象
 	 * @return int
@@ -314,7 +319,7 @@ public interface IService<T, PK> {
 	 * <p>
 	 * 翻页查询
 	 * </p>
-	 * 
+	 *
 	 * @param page
 	 *            翻页对象
 	 * @param entityWrapper

+ 229 - 212
mybatis-plus/src/main/java/com/baomidou/framework/service/impl/ServiceImpl.java

@@ -15,18 +15,6 @@
  */
 package com.baomidou.framework.service.impl;
 
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Logger;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.jdbc.datasource.DataSourceTransactionManager;
-import org.springframework.transaction.TransactionDefinition;
-import org.springframework.transaction.TransactionException;
-import org.springframework.transaction.TransactionStatus;
-import org.springframework.transaction.support.DefaultTransactionDefinition;
-
 import com.baomidou.framework.service.IService;
 import com.baomidou.mybatisplus.annotations.IdType;
 import com.baomidou.mybatisplus.exceptions.MybatisPlusException;
@@ -37,6 +25,13 @@ import com.baomidou.mybatisplus.toolkit.CollectionUtil;
 import com.baomidou.mybatisplus.toolkit.ReflectionKit;
 import com.baomidou.mybatisplus.toolkit.TableInfo;
 import com.baomidou.mybatisplus.toolkit.TableInfoHelper;
+import org.apache.ibatis.session.ExecutorType;
+import org.apache.ibatis.session.SqlSession;
+import org.springframework.beans.factory.annotation.Autowired;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
 
 /**
  * <p>
@@ -46,206 +41,228 @@ import com.baomidou.mybatisplus.toolkit.TableInfoHelper;
  * @author hubin
  * @Date 2016-04-20
  */
-public class ServiceImpl<M extends BaseMapper<T, PK>, T, PK extends Serializable> implements IService<T, PK> {
-
-	protected static final Logger logger = Logger.getLogger("ServiceImpl");
-
-	@Autowired
-	protected M baseMapper;
-
-	/**
-	 * 判断数据库操作是否成功
-	 *
-	 * @param result
-	 *            数据库操作返回影响条数
-	 * @return boolean
-	 */
-	protected boolean retBool(int result) {
-		return result >= 1;
-	}
-
-	/**
-	 * <p>
-	 * TableId 注解存在更新记录,否插入一条记录
-	 * </p>
-	 *
-	 * @param entity
-	 *            实体对象
-	 * @param isSelective
-	 *            true 选择字段 false 不选择字段
-	 * @return boolean
-	 */
-	public boolean insertOrUpdate(T entity, boolean isSelective) {
-		if (null != entity) {
-			Class<?> cls = entity.getClass();
-			TableInfo tableInfo = TableInfoHelper.getTableInfo(cls);
-			if (null != tableInfo) {
-				Object idVal = ReflectionKit.getMethodValue(cls, entity, tableInfo.getKeyProperty());
-				if (null == idVal || "".equals(idVal)) {
-					return isSelective ? insertSelective(entity) : insert(entity);
-				} else {
+public class ServiceImpl<M extends BaseMapper<T>, T> implements IService<T> {
+
+    protected Class<T> modleClass = ReflectionKit.getSuperClassGenricType(getClass(), 1);
+
+    protected static final Logger logger = Logger.getLogger("ServiceImpl");
+
+    @Autowired
+    protected M baseMapper;
+
+    /**
+     * 判断数据库操作是否成功
+     *
+     * @param result
+     *            数据库操作返回影响条数
+     * @return boolean
+     */
+    protected boolean retBool(int result) {
+        return result >= 1;
+    }
+
+    /**
+     * <p>
+     * TableId 注解存在更新记录,否插入一条记录
+     * </p>
+     *
+     * @param entity
+     *            实体对象
+     * @param isSelective
+     *            true 选择字段 false 不选择字段
+     * @return boolean
+     */
+    public boolean insertOrUpdate(T entity, boolean isSelective) {
+        if (null != entity) {
+            Class<?> cls = entity.getClass();
+            TableInfo tableInfo = TableInfoHelper.getTableInfo(cls);
+            if (null != tableInfo) {
+                Object idVal = ReflectionKit.getMethodValue(cls, entity, tableInfo.getKeyProperty());
+                if (null == idVal || "".equals(idVal)) {
+                    return isSelective ? insertSelective(entity) : insert(entity);
+                } else {
 					/* 特殊处理 INPUT 主键策略逻辑 */
-					if (IdType.INPUT == tableInfo.getIdType()) {
-						T entityValue = selectById((Serializable) idVal);
-						if (null != entityValue) {
-							return isSelective ? updateSelectiveById(entity) : updateById(entity);
-						} else {
-							return isSelective ? insertSelective(entity) : insert(entity);
-						}
-					}
-					return isSelective ? updateSelectiveById(entity) : updateById(entity);
-				}
-			} else {
-				throw new MybatisPlusException("Error:  Cannot execute. Could not find @TableId.");
-			}
-		}
-		return false;
-	}
-
-	public boolean insertOrUpdate(T entity) {
-		return insertOrUpdate(entity, false);
-	}
-
-	public boolean insertOrUpdateSelective(T entity) {
-		return insertOrUpdate(entity, true);
-	}
-
-	public boolean insert(T entity) {
-		return retBool(baseMapper.insert(entity));
-	}
-
-	public boolean insertSelective(T entity) {
-		return retBool(baseMapper.insertSelective(entity));
-	}
-
-	public boolean insertBatch(List<T> entityList) {
-		if (null == entityList) {
-			throw new IllegalArgumentException("entityList must not be empty");
-		}
-		return retBool(baseMapper.insertBatch(entityList));
-	}
-
-	public boolean insertBatch(DataSourceTransactionManager txManager, List<T> entityList, int batchSize) {
-		if (null == entityList) {
-			throw new IllegalArgumentException("entityList must not be empty");
-		}
-		TransactionDefinition def = new DefaultTransactionDefinition();
-		TransactionStatus status = txManager.getTransaction(def);
-		try {
-			int counter = 0;
-			for (T t : entityList) {
-				counter++;
-				baseMapper.insert(t);
-				if (counter % batchSize == 0) {
-					txManager.commit(status);
-					status = txManager.getTransaction(def);
-				}
-			}
-			txManager.commit(status);
-		} catch (TransactionException e) {
-			txManager.rollback(status);
-			e.printStackTrace();
-			return false;
-		}
-		return true;
-	}
-
-	public boolean insertBatchSelective(List<T> entityList) {
-		if (null == entityList) {
-			throw new IllegalArgumentException("entityList must not be empty");
-		}
-		int result = 0;
-		for (T t : entityList) {
-			result = baseMapper.insertSelective(t);
-			if (result <= 0) {
-				break;
-			}
-		}
-		return retBool(result);
-	}
-
-	public boolean deleteById(Serializable id) {
-		return retBool(baseMapper.deleteById(id));
-	}
-
-	public boolean deleteByMap(Map<String, Object> columnMap) {
-		return retBool(baseMapper.deleteByMap(columnMap));
-	}
-
-	public boolean deleteSelective(T entity) {
-		return retBool(baseMapper.deleteSelective(entity));
-	}
-
-	public boolean deleteBatchIds(List<? extends Serializable> idList) {
-		return retBool(baseMapper.deleteBatchIds(idList));
-	}
-
-	public boolean updateById(T entity) {
-		return retBool(baseMapper.updateById(entity));
-	}
-
-	public boolean updateSelectiveById(T entity) {
-		return retBool(baseMapper.updateSelectiveById(entity));
-	}
-
-	public boolean update(T entity, T whereEntity) {
-		return retBool(baseMapper.update(entity, whereEntity));
-	}
-
-	public boolean updateSelective(T entity, T whereEntity) {
-		return retBool(baseMapper.updateSelective(entity, whereEntity));
-	}
-
-	public boolean updateBatchById(List<T> entityList) {
-		return retBool(baseMapper.updateBatchById(entityList));
-	}
-
-	public T selectById(Serializable id) {
-		return baseMapper.selectById(id);
-	}
-
-	public List<T> selectBatchIds(List<? extends Serializable> idList) {
-		return baseMapper.selectBatchIds(idList);
-	}
-
-	public List<T> selectByMap(Map<String, Object> columnMap) {
-		return baseMapper.selectByMap(columnMap);
-	}
-
-	public T selectOne(T entity) {
-		return baseMapper.selectOne(entity);
-	}
-
-	public T selectOne(EntityWrapper<T> entityWrapper) {
-		List<T> list = baseMapper.selectList(entityWrapper);
-		if (CollectionUtil.isNotEmpty(list)) {
-			int size = list.size();
-			if (size > 1) {
-				logger.warning("Warn: selectOne Method There are " + size + " results.");
-			}
-			return list.get(0);
-		}
-		return null;
-	}
-
-	public int selectCount(T entity) {
-		return baseMapper.selectCount(entity);
-	}
-
-	public int selectCount(EntityWrapper<T> entityWrapper) {
-		return baseMapper.selectCountByEw(entityWrapper);
-	}
-
-	public List<T> selectList(EntityWrapper<T> entityWrapper) {
-		return baseMapper.selectList(entityWrapper);
-	}
-
-	public Page<T> selectPage(Page<T> page, EntityWrapper<T> entityWrapper) {
-		if (null != entityWrapper) {
-			entityWrapper.orderBy(page.getOrderByField(), page.isAsc());
-		}
-		page.setRecords(baseMapper.selectPage(page, entityWrapper));
-		return page;
-	}
+                    if (IdType.INPUT == tableInfo.getIdType()) {
+                        T entityValue = selectById((Serializable) idVal);
+                        if (null != entityValue) {
+                            return isSelective ? updateSelectiveById(entity) : updateById(entity);
+                        } else {
+                            return isSelective ? insertSelective(entity) : insert(entity);
+                        }
+                    }
+                    return isSelective ? updateSelectiveById(entity) : updateById(entity);
+                }
+            } else {
+                throw new MybatisPlusException("Error:  Cannot execute. Could not find @TableId.");
+            }
+        }
+        return false;
+    }
+
+    public boolean insertOrUpdate(T entity) {
+        return insertOrUpdate(entity, false);
+    }
+
+    public boolean insertOrUpdateSelective(T entity) {
+        return insertOrUpdate(entity, true);
+    }
+
+    public boolean insert(T entity) {
+        return retBool(baseMapper.insert(entity));
+    }
+
+    public boolean insertSelective(T entity) {
+        return retBool(baseMapper.insertSelective(entity));
+    }
+
+    public boolean insertBatch(List<T> entityList) {
+        if (null == entityList) {
+            throw new IllegalArgumentException("entityList must not be empty");
+        }
+        return retBool(baseMapper.insertBatch(entityList));
+    }
+
+    public boolean insertBatchSelective(List<T> entityList, int batchSize) {
+        return insertBatch(entityList, batchSize, true);
+    }
+
+    public boolean insertBatch(List<T> entityList, int batchSize) {
+        return insertBatch(entityList, batchSize, false);
+    }
+
+    /**
+     * 批量插入
+     *
+     * @param entityList
+     * @param batchSize
+     * @param isSelective
+     * @return
+     */
+    protected boolean insertBatch(List<T> entityList, int batchSize, boolean isSelective) {
+        if (null == entityList) {
+            throw new IllegalArgumentException("entityList must not be empty");
+        }
+        TableInfo tableInfo = TableInfoHelper.getTableInfo(modleClass);
+        if (null == tableInfo) {
+            throw new MybatisPlusException("Error: insertBatch Fail, ClassGenricType not found .");
+        }
+        SqlSession batchSqlSession = tableInfo.getSqlSessionFactory().openSession(ExecutorType.BATCH, false);
+        try {
+            for (int i = 0; i < entityList.size(); i++) {
+                if (isSelective) {
+                    baseMapper.insertSelective(entityList.get(0));
+                } else {
+                    baseMapper.insert(entityList.get(0));
+                }
+                if (i % batchSize == 0) {
+                    batchSqlSession.flushStatements();
+                }
+            }
+            batchSqlSession.flushStatements();
+        } catch (Exception e) {
+            logger.warning("Warn: Method insertBatch Fail. Cause:" + e);
+            return false;
+        }
+        return true;
+
+    }
+
+    public boolean insertBatchSelective(List<T> entityList) {
+        if (null == entityList) {
+            throw new IllegalArgumentException("entityList must not be empty");
+        }
+        int result = 0;
+        for (T t : entityList) {
+            result = baseMapper.insertSelective(t);
+            if (result <= 0) {
+                break;
+            }
+        }
+        return retBool(result);
+    }
+
+    public boolean deleteById(Serializable id) {
+        return retBool(baseMapper.deleteById(id));
+    }
+
+    public boolean deleteByMap(Map<String, Object> columnMap) {
+        return retBool(baseMapper.deleteByMap(columnMap));
+    }
+
+    public boolean deleteSelective(T entity) {
+        return retBool(baseMapper.deleteSelective(entity));
+    }
+
+    public boolean deleteBatchIds(List<? extends Serializable> idList) {
+        return retBool(baseMapper.deleteBatchIds(idList));
+    }
+
+    public boolean updateById(T entity) {
+        return retBool(baseMapper.updateById(entity));
+    }
+
+    public boolean updateSelectiveById(T entity) {
+        return retBool(baseMapper.updateSelectiveById(entity));
+    }
+
+    public boolean update(T entity, T whereEntity) {
+        return retBool(baseMapper.update(entity, whereEntity));
+    }
+
+    public boolean updateSelective(T entity, T whereEntity) {
+        return retBool(baseMapper.updateSelective(entity, whereEntity));
+    }
+
+    public boolean updateBatchById(List<T> entityList) {
+        return retBool(baseMapper.updateBatchById(entityList));
+    }
+
+    public T selectById(Serializable id) {
+        return baseMapper.selectById(id);
+    }
+
+    public List<T> selectBatchIds(List<? extends Serializable> idList) {
+        return baseMapper.selectBatchIds(idList);
+    }
+
+    public List<T> selectByMap(Map<String, Object> columnMap) {
+        return baseMapper.selectByMap(columnMap);
+    }
+
+    public T selectOne(T entity) {
+        return baseMapper.selectOne(entity);
+    }
+
+    public T selectOne(EntityWrapper<T> entityWrapper) {
+        List<T> list = baseMapper.selectList(entityWrapper);
+        if (CollectionUtil.isNotEmpty(list)) {
+            int size = list.size();
+            if (size > 1) {
+                logger.warning("Warn: selectOne Method There are " + size + " results.");
+            }
+            return list.get(0);
+        }
+        return null;
+    }
+
+    public int selectCount(T entity) {
+        return baseMapper.selectCount(entity);
+    }
+
+    public int selectCount(EntityWrapper<T> entityWrapper) {
+        return baseMapper.selectCountByEw(entityWrapper);
+    }
+
+    public List<T> selectList(EntityWrapper<T> entityWrapper) {
+        return baseMapper.selectList(entityWrapper);
+    }
+
+    public Page<T> selectPage(Page<T> page, EntityWrapper<T> entityWrapper) {
+        if (null != entityWrapper) {
+            entityWrapper.orderBy(page.getOrderByField(), page.isAsc());
+        }
+        page.setRecords(baseMapper.selectPage(page, entityWrapper));
+        return page;
+    }
 
 }

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

@@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.mapper.DBType;
 import com.baomidou.mybatisplus.mapper.IMetaObjectHandler;
 import com.baomidou.mybatisplus.mapper.ISqlInjector;
 import org.apache.ibatis.binding.MapperRegistry;
+import org.apache.ibatis.mapping.Environment;
 import org.apache.ibatis.mapping.MappedStatement;
 import org.apache.ibatis.session.Configuration;
 import org.apache.ibatis.session.SqlSession;
@@ -91,6 +92,15 @@ public class MybatisConfiguration extends Configuration {
 		System.err.println("mybatis-plus init success.");
 	}
 
+	/**
+	 * JDBC开启ActiveRecord
+	 * 
+	 * @param environment
+	 */
+	public MybatisConfiguration(Environment environment) {
+		super(environment);
+	}
+
 	/**
 	 * <p>
 	 * MybatisPlus 加载 SQL 顺序:

+ 7 - 5
mybatis-plus/src/main/java/com/baomidou/mybatisplus/MybatisMapperRegistry.java

@@ -15,17 +15,17 @@
  */
 package com.baomidou.mybatisplus;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
 import org.apache.ibatis.binding.BindingException;
 import org.apache.ibatis.binding.MapperProxyFactory;
 import org.apache.ibatis.binding.MapperRegistry;
 import org.apache.ibatis.session.Configuration;
 import org.apache.ibatis.session.SqlSession;
 
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * <p>
  * 继承至MapperRegistry
@@ -42,6 +42,8 @@ public class MybatisMapperRegistry extends MapperRegistry {
 	public MybatisMapperRegistry(Configuration config) {
 		super(config);
 		this.config = config;
+		// TODO 注入全局CRUD SQL
+		MybatisConfiguration.SQL_INJECTOR.injectOfSql(config);
 	}
 
 	@SuppressWarnings("unchecked")

+ 8 - 9
mybatis-plus/src/main/java/com/baomidou/mybatisplus/MybatisSessionFactoryBuilder.java

@@ -15,20 +15,19 @@
  */
 package com.baomidou.mybatisplus;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.util.Properties;
-
+import com.baomidou.mybatisplus.annotations.FieldStrategy;
+import com.baomidou.mybatisplus.mapper.DBType;
+import com.baomidou.mybatisplus.mapper.IMetaObjectHandler;
+import com.baomidou.mybatisplus.mapper.ISqlInjector;
 import org.apache.ibatis.exceptions.ExceptionFactory;
 import org.apache.ibatis.executor.ErrorContext;
 import org.apache.ibatis.session.SqlSessionFactory;
 import org.apache.ibatis.session.SqlSessionFactoryBuilder;
 
-import com.baomidou.mybatisplus.annotations.FieldStrategy;
-import com.baomidou.mybatisplus.mapper.DBType;
-import com.baomidou.mybatisplus.mapper.IMetaObjectHandler;
-import com.baomidou.mybatisplus.mapper.ISqlInjector;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.util.Properties;
 
 /**
  * <p>

+ 1 - 2
mybatis-plus/src/main/java/com/baomidou/mybatisplus/MybatisXMLMapperBuilder.java

@@ -70,7 +70,7 @@ public class MybatisXMLMapperBuilder extends BaseBuilder {
 
 	@Deprecated
 	public MybatisXMLMapperBuilder(Reader reader, Configuration configuration, String resource,
-			Map<String, XNode> sqlFragments, String namespace) {
+								   Map<String, XNode> sqlFragments, String namespace) {
 		this(reader, configuration, resource, sqlFragments);
 		this.builderAssistant.setCurrentNamespace(namespace);
 	}
@@ -109,7 +109,6 @@ public class MybatisXMLMapperBuilder extends BaseBuilder {
 			configuration.addLoadedResource(resource);
 			bindMapperForNamespace();
 		}
-
 		parsePendingResultMaps();
 		parsePendingChacheRefs();
 		parsePendingStatements();

+ 8 - 8
mybatis-plus/src/main/java/com/baomidou/mybatisplus/generator/AutoGenerator.java

@@ -15,6 +15,12 @@
  */
 package com.baomidou.mybatisplus.generator;
 
+import com.baomidou.mybatisplus.annotations.IdType;
+import com.baomidou.mybatisplus.exceptions.MybatisPlusException;
+import com.baomidou.mybatisplus.mapper.DBType;
+import com.baomidou.mybatisplus.toolkit.SqlReservedWords;
+import com.baomidou.mybatisplus.toolkit.StringUtils;
+
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileOutputStream;
@@ -31,12 +37,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import com.baomidou.mybatisplus.annotations.IdType;
-import com.baomidou.mybatisplus.exceptions.MybatisPlusException;
-import com.baomidou.mybatisplus.mapper.DBType;
-import com.baomidou.mybatisplus.toolkit.SqlReservedWords;
-import com.baomidou.mybatisplus.toolkit.StringUtils;
-
 /**
  * <p>
  * 映射文件自动生成类
@@ -469,7 +469,7 @@ public class AutoGenerator {
 
 	/**
 	 * 字段处理
-	 * 
+	 *
 	 * @param field
 	 *            表字段
 	 * @return
@@ -580,7 +580,7 @@ public class AutoGenerator {
 			bw.write("@TableName(\"" + table + "\")");
 			bw.newLine();
 		}
-		
+
 		/**
 		 * 实体类名处理,开启 BaseEntity 继承父类
 		 */

+ 2 - 10
mybatis-plus/src/main/java/com/baomidou/mybatisplus/generator/ConfigGenerator.java

@@ -173,11 +173,7 @@ public class ConfigGenerator {
 
 	public String getSuperService() {
 		if (StringUtils.isEmpty(superService)) {
-			if (this.getConfigIdType() == ConfigIdType.STRING) {
-				return "com.baomidou.framework.service.ICommonService";
-			} else {
-				return "com.baomidou.framework.service.ISuperService";
-			}
+			return "com.baomidou.framework.service.IService";
 		}
 		return superService;
 	}
@@ -188,11 +184,7 @@ public class ConfigGenerator {
 
 	public String getSuperServiceImpl() {
 		if (StringUtils.isEmpty(superServiceImpl)) {
-			if (this.getConfigIdType() == ConfigIdType.STRING) {
-				return "com.baomidou.framework.service.impl.CommonServiceImpl";
-			} else {
-				return "com.baomidou.framework.service.impl.SuperServiceImpl";
-			}
+			return "com.baomidou.framework.service.impl.ServiceImpl";
 		}
 		return superServiceImpl;
 	}

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

@@ -45,7 +45,7 @@ import com.baomidou.mybatisplus.toolkit.TableInfoHelper;
  * <p>
  * SQL 自动注入器
  * </p>
- * 
+ *
  * @author hubin sjy
  * @Date 2016-09-09
  */
@@ -85,7 +85,7 @@ public class AutoSqlInjector implements ISqlInjector {
 		this.languageDriver = configuration.getDefaultScriptingLanuageInstance();
 		this.dbType = MybatisConfiguration.DB_TYPE;
 		/*
-		 * 驼峰设置 PLUS 配置 > 原始配置 
+		 * 驼峰设置 PLUS 配置 > 原始配置
 		 */
 		if (!MybatisConfiguration.DB_COLUMN_UNDERLINE) {
 			MybatisConfiguration.DB_COLUMN_UNDERLINE = configuration.isMapUnderscoreToCamelCase();
@@ -140,7 +140,7 @@ public class AutoSqlInjector implements ISqlInjector {
 	 * 自定义方法,注入点(子类需重写该方法)
 	 */
 	public void inject(Configuration configuration, MapperBuilderAssistant builderAssistant, Class<?> mapperClass,
-			Class<?> modelClass, TableInfo table) {
+					   Class<?> modelClass, TableInfo table) {
 		// to do nothing
 	}
 
@@ -162,7 +162,7 @@ public class AutoSqlInjector implements ISqlInjector {
 	 * <p>
 	 * 注入插入 SQL 语句
 	 * </p>
-	 * 
+	 *
 	 * @param selective
 	 *            是否选择插入
 	 * @param mapperClass
@@ -223,7 +223,7 @@ public class AutoSqlInjector implements ISqlInjector {
 	 * <p>
 	 * 注入批量插入 SQL 语句
 	 * </p>
-	 * 
+	 *
 	 * @param mapperClass
 	 * @param modelClass
 	 * @param table
@@ -270,7 +270,7 @@ public class AutoSqlInjector implements ISqlInjector {
 	 * <p>
 	 * 注入 entity 条件删除 SQL 语句
 	 * </p>
-	 * 
+	 *
 	 * @param mapperClass
 	 * @param modelClass
 	 * @param table
@@ -286,7 +286,7 @@ public class AutoSqlInjector implements ISqlInjector {
 	 * <p>
 	 * 注入 map 条件删除 SQL 语句
 	 * </p>
-	 * 
+	 *
 	 * @param mapperClass
 	 * @param table
 	 */
@@ -301,7 +301,7 @@ public class AutoSqlInjector implements ISqlInjector {
 	 * <p>
 	 * 注入删除 SQL 语句
 	 * </p>
-	 * 
+	 *
 	 * @param batch
 	 *            是否为批量插入
 	 * @param mapperClass
@@ -330,7 +330,7 @@ public class AutoSqlInjector implements ISqlInjector {
 	 * <p>
 	 * 注入更新 SQL 语句
 	 * </p>
-	 * 
+	 *
 	 * @param selective
 	 *            是否选择更新
 	 * @param mapperClass
@@ -352,7 +352,7 @@ public class AutoSqlInjector implements ISqlInjector {
 	 * <p>
 	 * 注入批量更新 SQL 语句
 	 * </p>
-	 * 
+	 *
 	 * @param mapperClass
 	 * @param modelClass
 	 * @param table
@@ -392,7 +392,7 @@ public class AutoSqlInjector implements ISqlInjector {
 	 * <p>
 	 * 注入批量更新 SQL 语句
 	 * </p>
-	 * 
+	 *
 	 * @param selective
 	 *            是否选择更新
 	 * @param mapperClass
@@ -413,7 +413,7 @@ public class AutoSqlInjector implements ISqlInjector {
 	 * <p>
 	 * 注入查询 SQL 语句
 	 * </p>
-	 * 
+	 *
 	 * @param batch
 	 *            是否为批量插入
 	 * @param mapperClass
@@ -442,7 +442,7 @@ public class AutoSqlInjector implements ISqlInjector {
 	 * <p>
 	 * 注入 map 查询 SQL 语句
 	 * </p>
-	 * 
+	 *
 	 * @param mapperClass
 	 * @param modelClass
 	 * @param table
@@ -458,7 +458,7 @@ public class AutoSqlInjector implements ISqlInjector {
 	 * <p>
 	 * 注入实体查询一条记录 SQL 语句
 	 * </p>
-	 * 
+	 *
 	 * @param mapperClass
 	 * @param modelClass
 	 * @param table
@@ -475,7 +475,7 @@ public class AutoSqlInjector implements ISqlInjector {
 	 * <p>
 	 * 注入实体查询总记录数 SQL 语句
 	 * </p>
-	 * 
+	 *
 	 * @param mapperClass
 	 * @param modelClass
 	 * @param table
@@ -548,7 +548,7 @@ public class AutoSqlInjector implements ISqlInjector {
 	 * <p>
 	 * SQL 更新 set 语句
 	 * </p>
-	 * 
+	 *
 	 * @param selective
 	 *            是否选择更新
 	 * @param table
@@ -575,7 +575,7 @@ public class AutoSqlInjector implements ISqlInjector {
 	 * <p>
 	 * SQL 查询所有表字段
 	 * </p>
-	 * 
+	 *
 	 * @param table
 	 * @param entityWrapper
 	 *            是否为包装类型查询
@@ -628,7 +628,7 @@ public class AutoSqlInjector implements ISqlInjector {
 	 * <p>
 	 * SQL 查询条件
 	 * </p>
-	 * 
+	 *
 	 * @param table
 	 * @param space
 	 *            是否为空判断
@@ -676,7 +676,7 @@ public class AutoSqlInjector implements ISqlInjector {
 	 * <p>
 	 * IF 条件转换方法
 	 * </p>
-	 * 
+	 *
 	 * @param sqlCommandType
 	 *            SQL 操作类型
 	 * @param fieldInfo
@@ -688,7 +688,7 @@ public class AutoSqlInjector implements ISqlInjector {
 	 * @return
 	 */
 	protected String convertIfTag(SqlCommandType sqlCommandType, TableFieldInfo fieldInfo, String prefix,
-			boolean colse) {
+								  boolean colse) {
 		/* 前缀处理 */
 		String property = fieldInfo.getProperty();
 		if (null != prefix) {
@@ -716,7 +716,7 @@ public class AutoSqlInjector implements ISqlInjector {
 			}
 		}
 	}
-	
+
 	protected String convertIfTagInsert(TableFieldInfo fieldInfo, boolean colse) {
 		return convertIfTag(SqlCommandType.INSERT, fieldInfo, null, colse);
 	}
@@ -733,7 +733,7 @@ public class AutoSqlInjector implements ISqlInjector {
 	 * 查询
 	 */
 	public MappedStatement addSelectMappedStatement(Class<?> mapperClass, String id, SqlSource sqlSource, Class<?> resultType,
-			TableInfo table) {
+													TableInfo table) {
 		if (null != table) {
 			String resultMap = table.getResultMap();
 			if (null != resultMap) {
@@ -752,7 +752,7 @@ public class AutoSqlInjector implements ISqlInjector {
 	 * 插入
 	 */
 	public MappedStatement addInsertMappedStatement(Class<?> mapperClass, Class<?> modelClass, String id, SqlSource sqlSource,
-			KeyGenerator keyGenerator, String keyProperty, String keyColumn) {
+													KeyGenerator keyGenerator, String keyProperty, String keyColumn) {
 		return this.addMappedStatement(mapperClass, id, sqlSource, SqlCommandType.INSERT, modelClass, null, Integer.class,
 				keyGenerator, keyProperty, keyColumn);
 	}
@@ -774,8 +774,8 @@ public class AutoSqlInjector implements ISqlInjector {
 	}
 
 	public MappedStatement addMappedStatement(Class<?> mapperClass, String id, SqlSource sqlSource,
-			SqlCommandType sqlCommandType, Class<?> parameterClass, String resultMap, Class<?> resultType,
-			KeyGenerator keyGenerator, String keyProperty, String keyColumn) {
+											  SqlCommandType sqlCommandType, Class<?> parameterClass, String resultMap, Class<?> resultType,
+											  KeyGenerator keyGenerator, String keyProperty, String keyColumn) {
 		String statementName = mapperClass.getName() + "." + id;
 		if (configuration.hasStatement(statementName)) {
 			System.err.println("{" + statementName

+ 1 - 1
mybatis-plus/src/main/java/com/baomidou/mybatisplus/mapper/BaseMapper.java

@@ -33,7 +33,7 @@ import java.util.Map;
  * @author hubin
  * @Date 2016-01-23
  */
-public interface BaseMapper<T, PK extends Serializable> {
+public interface BaseMapper<T> {
 
 	/**
 	 * <p>

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

@@ -29,19 +29,20 @@ import org.apache.ibatis.session.Configuration;
 public interface ISqlInjector {
 
 	/**
-	 * <p>
-	 * 注入 SQL
-	 * </p>
+	 * 根据mapperClass注入SQL
+	 * 
+	 * @param configuration
+	 * @param builderAssistant
+	 * @param mapperClass
 	 */
 	void inject(Configuration configuration, MapperBuilderAssistant builderAssistant, Class<?> mapperClass);
 
 	/**
-	 * <p>
-	 * 检查SQL是否已经注入
-	 * </p>
-	 * <p>
-	 * ps:注入基本SQL后给予标识 注入过不再注入
-	 * </p>
+	 * 检查SQL是否注入(已经注入过不再注入)
+	 * 
+	 * @param configuration
+	 * @param builderAssistant
+	 * @param mapperClass
 	 */
 	void inspectInject(Configuration configuration, MapperBuilderAssistant builderAssistant, Class<?> mapperClass);
 

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

@@ -24,6 +24,7 @@ import com.baomidou.mybatisplus.mapper.DBType;
 import com.baomidou.mybatisplus.mapper.IMetaObjectHandler;
 import com.baomidou.mybatisplus.mapper.ISqlInjector;
 import com.baomidou.mybatisplus.toolkit.PackageHelper;
+import com.baomidou.mybatisplus.toolkit.TableInfoHelper;
 import org.apache.ibatis.cache.Cache;
 import org.apache.ibatis.executor.ErrorContext;
 import org.apache.ibatis.io.VFS;
@@ -70,8 +71,8 @@ import static org.springframework.util.StringUtils.tokenizeToStringArray;
  * @author hubin
  * @Date 2016-01-23
  */
-public class MybatisSqlSessionFactoryBean
-		implements FactoryBean<SqlSessionFactory>, InitializingBean, ApplicationListener<ApplicationEvent> {
+public class MybatisSqlSessionFactoryBean implements FactoryBean<SqlSessionFactory>, InitializingBean,
+		ApplicationListener<ApplicationEvent> {
 
 	private static final Log LOGGER = LogFactory.getLog(MybatisSqlSessionFactoryBean.class);
 
@@ -458,8 +459,7 @@ public class MybatisSqlSessionFactoryBean
 			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();
@@ -578,9 +578,8 @@ public class MybatisSqlSessionFactoryBean
 
 				try {
 					// TODO
-					MybatisXMLMapperBuilder xmlMapperBuilder = new MybatisXMLMapperBuilder(
-							mapperLocation.getInputStream(), configuration, mapperLocation.toString(),
-							configuration.getSqlFragments());
+					MybatisXMLMapperBuilder xmlMapperBuilder = new MybatisXMLMapperBuilder(mapperLocation.getInputStream(),
+							configuration, mapperLocation.toString(), configuration.getSqlFragments());
 					xmlMapperBuilder.parse();
 				} catch (Exception e) {
 					throw new NestedIOException("Failed to parse mapping resource: '" + mapperLocation + "'", e);
@@ -597,8 +596,10 @@ public class MybatisSqlSessionFactoryBean
 				LOGGER.debug("Property 'mapperLocations' was not specified or no matching resources found");
 			}
 		}
-
-		return this.sqlSessionFactoryBuilder.build(configuration);
+		SqlSessionFactory sqlSessionFactory = this.sqlSessionFactoryBuilder.build(configuration);
+		// TODO 缓存 sqlSessionFactory
+		TableInfoHelper.cacheSqlSessionFactory(sqlSessionFactory);
+		return sqlSessionFactory;
 	}
 
 	/**
@@ -608,7 +609,6 @@ public class MybatisSqlSessionFactoryBean
 		if (this.sqlSessionFactory == null) {
 			afterPropertiesSet();
 		}
-
 		return this.sqlSessionFactory;
 	}
 

+ 35 - 0
mybatis-plus/src/main/java/com/baomidou/mybatisplus/toolkit/ReflectionKit.java

@@ -17,6 +17,8 @@ package com.baomidou.mybatisplus.toolkit;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
 import java.util.List;
 import java.util.logging.Logger;
 
@@ -115,4 +117,37 @@ public class ReflectionKit {
 		return result;
 	}
 
+	/**
+	 * 反射对象获取泛型
+	 * 
+	 * @param clazz
+	 *            对象
+	 * @param index
+	 *            泛型所在位置
+	 * @return Class
+	 */
+	public static Class getSuperClassGenricType(final Class clazz, final int index) {
+
+		Type genType = clazz.getGenericSuperclass();
+
+		if (!(genType instanceof ParameterizedType)) {
+			logger.warning(String.format("Warn: %s's superclass not ParameterizedType", clazz.getSimpleName()));
+			return Object.class;
+		}
+
+		Type[] params = ((ParameterizedType) genType).getActualTypeArguments();
+
+		if (index >= params.length || index < 0) {
+			logger.warning(String.format("Warn: " + "Index: %s, Size of %s's Parameterized Type: %s .", index,
+					clazz.getSimpleName(), params.length));
+			return Object.class;
+		}
+		if (!(params[index] instanceof Class)) {
+			logger.warning(String.format("Warn: %s not set the actual class on superclass generic parameter",
+					clazz.getSimpleName()));
+			return Object.class;
+		}
+
+		return (Class) params[index];
+	}
 }

+ 3 - 3
mybatis-plus/src/main/java/com/baomidou/mybatisplus/toolkit/Sequence.java

@@ -68,11 +68,11 @@ public class Sequence {
 	public Sequence(long workerId, long datacenterId) {
 		if (workerId > maxWorkerId || workerId < 0) {
 			throw new MybatisPlusException(
-					String.format("worker Id can't be greater than %d or less than 0", maxWorkerId));
+					String.format("worker Id can't be greater than %dialect or less than 0", maxWorkerId));
 		}
 		if (datacenterId > maxDatacenterId || datacenterId < 0) {
 			throw new MybatisPlusException(
-					String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId));
+					String.format("datacenter Id can't be greater than %dialect or less than 0", maxDatacenterId));
 		}
 		this.workerId = workerId;
 		this.datacenterId = datacenterId;
@@ -87,7 +87,7 @@ public class Sequence {
 		long timestamp = timeGen();
 		if (timestamp < lastTimestamp) {
 			throw new MybatisPlusException(String.format(
-					"Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
+					"Clock moved backwards. Refusing to generate id for %dialect milliseconds", lastTimestamp - timestamp));
 		}
 		if (lastTimestamp == timestamp) {
 			sequence = (sequence + 1) & sequenceMask;

+ 68 - 26
mybatis-plus/src/main/java/com/baomidou/mybatisplus/toolkit/StringEscape.java

@@ -2,7 +2,7 @@ package com.baomidou.mybatisplus.toolkit;
 
 /**
  * <p>
- * EscapeOfString ,数据库字符串转义
+ * StringEscape ,数据库字符串转义
  * </p>
  *
  * @author Caratacus
@@ -11,7 +11,7 @@ package com.baomidou.mybatisplus.toolkit;
 public class StringEscape {
 	/**
 	 * 字符串是否需要转义
-	 * 
+	 *
 	 * @param x
 	 * @param stringLength
 	 * @return
@@ -24,21 +24,38 @@ public class StringEscape {
 			char c = x.charAt(i);
 
 			switch (c) {
-			case '\\':
-				needsHexEscape = true;
+				case 0: /* Must be escaped for 'mysql' */
 
-				break;
+					needsHexEscape = true;
+					break;
+
+				case '\n': /* Must be escaped for logs */
+					needsHexEscape = true;
+
+					break;
 
-			case '\'':
-				needsHexEscape = true;
+				case '\r':
+					needsHexEscape = true;
+					break;
 
-				break;
+				case '\\':
+					needsHexEscape = true;
 
-			case '"': /* Better safe than sorry */
-				needsHexEscape = true;
+					break;
 
-				break;
+				case '\'':
+					needsHexEscape = true;
 
+					break;
+
+				case '"': /* Better safe than sorry */
+					needsHexEscape = true;
+
+					break;
+
+				case '\032': /* This gives problems on Win32 */
+					needsHexEscape = true;
+					break;
 			}
 
 			if (needsHexEscape) {
@@ -50,7 +67,7 @@ public class StringEscape {
 
 	/**
 	 * 转义字符串
-	 * 
+	 *
 	 * @param x
 	 * @return
 	 */
@@ -76,25 +93,50 @@ public class StringEscape {
 				char c = x.charAt(i);
 
 				switch (c) {
+					case 0: /* Must be escaped for 'mysql' */
+						buf.append('\\');
+						buf.append('0');
 
-				case '\\':
-					buf.append('\\');
-					buf.append('\\');
+						break;
 
-					break;
+					case '\n': /* Must be escaped for logs */
+						buf.append('\\');
+						buf.append('n');
 
-				case '\'':
-					buf.append('\\');
-					buf.append('\'');
-					break;
+						break;
 
-				case '"': /* Better safe than sorry */
-					buf.append('\\');
-					buf.append('"');
-					break;
+					case '\r':
+						buf.append('\\');
+						buf.append('r');
+
+						break;
+
+					case '\\':
+						buf.append('\\');
+						buf.append('\\');
+
+						break;
+
+					case '\'':
+						buf.append('\\');
+						buf.append('\'');
+
+						break;
+
+					case '"': /* Better safe than sorry */
+						buf.append('\\');
+						buf.append('"');
+
+						break;
+
+					case '\032': /* This gives problems on Win32 */
+						buf.append('\\');
+						buf.append('Z');
+
+						break;
 
-				default:
-					buf.append(c);
+					default:
+						buf.append(c);
 				}
 			}
 

+ 14 - 3
mybatis-plus/src/main/java/com/baomidou/mybatisplus/toolkit/TableInfo.java

@@ -15,9 +15,10 @@
  */
 package com.baomidou.mybatisplus.toolkit;
 
-import java.util.List;
-
 import com.baomidou.mybatisplus.annotations.IdType;
+import org.apache.ibatis.session.SqlSessionFactory;
+
+import java.util.List;
 
 /**
  * <p>
@@ -61,7 +62,10 @@ public class TableInfo {
 	 * 表主键ID 字段名
 	 */
 	private String keyColumn;
-
+	/**
+	 * 缓存SqlSessionFactory
+	 */
+	private SqlSessionFactory sqlSessionFactory;
 	/**
 	 * 表字段信息列表
 	 */
@@ -123,4 +127,11 @@ public class TableInfo {
 		this.fieldList = fieldList;
 	}
 
+	public SqlSessionFactory getSqlSessionFactory() {
+		return sqlSessionFactory;
+	}
+
+	public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
+		this.sqlSessionFactory = sqlSessionFactory;
+	}
 }

+ 161 - 142
mybatis-plus/src/main/java/com/baomidou/mybatisplus/toolkit/TableInfoHelper.java

@@ -15,193 +15,212 @@
  */
 package com.baomidou.mybatisplus.toolkit;
 
+import com.baomidou.mybatisplus.MybatisConfiguration;
+import com.baomidou.mybatisplus.annotations.TableField;
+import com.baomidou.mybatisplus.annotations.TableId;
+import com.baomidou.mybatisplus.annotations.TableName;
+import com.baomidou.mybatisplus.exceptions.MybatisPlusException;
+import org.apache.ibatis.session.SqlSessionFactory;
+
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import com.baomidou.mybatisplus.MybatisConfiguration;
-import com.baomidou.mybatisplus.annotations.TableField;
-import com.baomidou.mybatisplus.annotations.TableId;
-import com.baomidou.mybatisplus.annotations.TableName;
-import com.baomidou.mybatisplus.exceptions.MybatisPlusException;
-
 /**
  * <p>
  * 实体类反射表辅助类
  * </p>
- * 
+ *
  * @author hubin sjy
  * @Date 2016-09-09
  */
 public class TableInfoHelper {
 
-	/**
-	 * 缓存反射类表信息
-	 */
-	private static Map<String, TableInfo> tableInfoCache = new ConcurrentHashMap<String, TableInfo>();
-
-	/**
-	 * <p>
-	 * 获取实体映射表信息
-	 * <p>
-	 * 
-	 * @param clazz
-	 *            反射实体类
-	 * @return
-	 */
-	public static TableInfo getTableInfo(Class<?> clazz) {
-		return tableInfoCache.get(clazz.getName());
-	}
-
-	/**
-	 * <p>
-	 * 实体类反射获取表信息【初始化】
-	 * <p>
-	 * 
-	 * @param clazz
-	 *            反射实体类
-	 * @return
-	 */
-	public synchronized static TableInfo initTableInfo(Class<?> clazz) {
-		TableInfo ti = tableInfoCache.get(clazz.getName());
-		if (ti != null) {
-			return ti;
-		}
-		TableInfo tableInfo = new TableInfo();
+    /**
+     * 缓存反射类表信息
+     */
+    private static Map<String, TableInfo> tableInfoCache = new ConcurrentHashMap<String, TableInfo>();
+
+    /**
+     * <p>
+     * 获取实体映射表信息
+     * <p>
+     *
+     * @param clazz
+     *            反射实体类
+     * @return
+     */
+    public static TableInfo getTableInfo(Class<?> clazz) {
+        return tableInfoCache.get(clazz.getName());
+    }
+
+    /**
+     * <p>
+     * 实体类反射获取表信息【初始化】
+     * <p>
+     *
+     * @param clazz
+     *            反射实体类
+     * @return
+     */
+    public synchronized static TableInfo initTableInfo(Class<?> clazz) {
+        TableInfo ti = tableInfoCache.get(clazz.getName());
+        if (ti != null) {
+            return ti;
+        }
+        TableInfo tableInfo = new TableInfo();
 
 		/* 表名 */
-		TableName table = clazz.getAnnotation(TableName.class);
-		if (table != null && StringUtils.isNotEmpty(table.value())) {
-			tableInfo.setTableName(table.value());
-		} else {
-			tableInfo.setTableName(StringUtils.camelToUnderline(clazz.getSimpleName()));
-		}
-		
+        TableName table = clazz.getAnnotation(TableName.class);
+        if (table != null && StringUtils.isNotEmpty(table.value())) {
+            tableInfo.setTableName(table.value());
+        } else {
+            tableInfo.setTableName(StringUtils.camelToUnderline(clazz.getSimpleName()));
+        }
+
 		/* 表结果集映射 */
-		if (table != null && StringUtils.isNotEmpty(table.resultMap())) {
-			tableInfo.setResultMap(table.resultMap());
-		}
-
-		List<TableFieldInfo> fieldList = new ArrayList<TableFieldInfo>();
-		List<Field> list = getAllFields(clazz);
-		for (Field field : list) {
-			/**
-			 * 主键ID
-			 */
-			TableId tableId = field.getAnnotation(TableId.class);
-			if (tableId != null) {
-				if (tableInfo.getKeyColumn() == null) {
-					tableInfo.setIdType(tableId.type());
-					if (StringUtils.isNotEmpty(tableId.value())) {
+        if (table != null && StringUtils.isNotEmpty(table.resultMap())) {
+            tableInfo.setResultMap(table.resultMap());
+        }
+
+        List<TableFieldInfo> fieldList = new ArrayList<TableFieldInfo>();
+        List<Field> list = getAllFields(clazz);
+        for (Field field : list) {
+            /**
+             * 主键ID
+             */
+            TableId tableId = field.getAnnotation(TableId.class);
+            if (tableId != null) {
+                if (tableInfo.getKeyColumn() == null) {
+                    tableInfo.setIdType(tableId.type());
+                    if (StringUtils.isNotEmpty(tableId.value())) {
 						/* 自定义字段 */
-						tableInfo.setKeyColumn(tableId.value());
-						tableInfo.setKeyRelated(true);
-					} else if (MybatisConfiguration.DB_COLUMN_UNDERLINE) {
+                        tableInfo.setKeyColumn(tableId.value());
+                        tableInfo.setKeyRelated(true);
+                    } else if (MybatisConfiguration.DB_COLUMN_UNDERLINE) {
 						/* 开启字段下划线申明 */
-						tableInfo.setKeyColumn(StringUtils.camelToUnderline(field.getName()));
-					} else {
-						tableInfo.setKeyColumn(field.getName());
-					}
-					tableInfo.setKeyProperty(field.getName());
-					continue;
-				} else {
+                        tableInfo.setKeyColumn(StringUtils.camelToUnderline(field.getName()));
+                    } else {
+                        tableInfo.setKeyColumn(field.getName());
+                    }
+                    tableInfo.setKeyProperty(field.getName());
+                    continue;
+                } else {
 					/* 发现设置多个主键注解抛出异常 */
-					throw new MybatisPlusException("There must be only one, Discover multiple @TableId annotation in " + clazz);
-				}
-			}
+                    throw new MybatisPlusException("There must be only one, Discover multiple @TableId annotation in " + clazz);
+                }
+            }
 
 			/* 获取注解属性,自定义字段 */
-			TableField tableField = field.getAnnotation(TableField.class);
-			if (tableField != null) {
-				String columnName = field.getName();
-				if (StringUtils.isNotEmpty(tableField.value())) {
-					columnName = tableField.value();
-				}
+            TableField tableField = field.getAnnotation(TableField.class);
+            if (tableField != null) {
+                String columnName = field.getName();
+                if (StringUtils.isNotEmpty(tableField.value())) {
+                    columnName = tableField.value();
+                }
 
 				/*
 				 * el 语法支持,可以传入多个参数以逗号分开
 				 */
-				String el = field.getName();
-				if (StringUtils.isNotEmpty(tableField.el())) {
-					el = tableField.el();
-				}
-				String[] columns = columnName.split(";");
-				String[] els = el.split(";");
-				if (null != columns && null != els && columns.length == els.length) {
-					for (int i = 0; i < columns.length; i++) {
-						fieldList.add(new TableFieldInfo(true, columns[i], field.getName(), els[i], tableField.validate()));
-					}
-				} else {
-					String errorMsg = "Class: %s, Field: %s, 'value' 'el' Length must be consistent.";
-					throw new MybatisPlusException(String.format(errorMsg, clazz.getName(), field.getName()));
-				}
-
-				continue;
-			}
-
-			/**
-			 * 字段, 使用 camelToUnderline 转换驼峰写法为下划线分割法, 如果已指定 TableField , 便不会执行这里
-			 */
-			if (MybatisConfiguration.DB_COLUMN_UNDERLINE) {
+                String el = field.getName();
+                if (StringUtils.isNotEmpty(tableField.el())) {
+                    el = tableField.el();
+                }
+                String[] columns = columnName.split(";");
+                String[] els = el.split(";");
+                if (null != columns && null != els && columns.length == els.length) {
+                    for (int i = 0; i < columns.length; i++) {
+                        fieldList.add(new TableFieldInfo(true, columns[i], field.getName(), els[i], tableField.validate()));
+                    }
+                } else {
+                    String errorMsg = "Class: %s, Field: %s, 'value' 'el' Length must be consistent.";
+                    throw new MybatisPlusException(String.format(errorMsg, clazz.getName(), field.getName()));
+                }
+
+                continue;
+            }
+
+            /**
+             * 字段, 使用 camelToUnderline 转换驼峰写法为下划线分割法, 如果已指定 TableField , 便不会执行这里
+             */
+            if (MybatisConfiguration.DB_COLUMN_UNDERLINE) {
 				/* 开启字段下划线申明 */
-				fieldList.add(new TableFieldInfo(true, StringUtils.camelToUnderline(field.getName()), field.getName()));
-			} else {
-				fieldList.add(new TableFieldInfo(field.getName()));
-			}
-		}
+                fieldList.add(new TableFieldInfo(true, StringUtils.camelToUnderline(field.getName()), field.getName()));
+            } else {
+                fieldList.add(new TableFieldInfo(field.getName()));
+            }
+        }
 
 		/* 字段列表 */
-		tableInfo.setFieldList(fieldList);
+        tableInfo.setFieldList(fieldList);
 
 		/*
 		 * 未发现主键注解,跳过注入
 		 */
-		if (null == tableInfo.getKeyColumn()) {
-			return null;
-		}
+        if (null == tableInfo.getKeyColumn()) {
+            return null;
+        }
 
 		/*
 		 * 注入
 		 */
-		tableInfoCache.put(clazz.getName(), tableInfo);
-		return tableInfo;
-	}
-
-	/**
-	 * 获取该类的所有属性列表
-	 * 
-	 * @param clazz
-	 *            反射类
-	 * @return
-	 */
-	private static List<Field> getAllFields(Class<?> clazz) {
-		List<Field> result = new LinkedList<Field>();
-		Field[] fields = clazz.getDeclaredFields();
-		for (Field field : fields) {
+        tableInfoCache.put(clazz.getName(), tableInfo);
+        return tableInfo;
+    }
+
+    /**
+     * 获取该类的所有属性列表
+     *
+     * @param clazz
+     *            反射类
+     * @return
+     */
+    private static List<Field> getAllFields(Class<?> clazz) {
+        List<Field> result = new LinkedList<Field>();
+        Field[] fields = clazz.getDeclaredFields();
+        for (Field field : fields) {
 
 			/* 过滤 transient关键字修饰的属性 */
-			if (Modifier.isTransient(field.getModifiers())) {
-				continue;
-			}
+            if (Modifier.isTransient(field.getModifiers())) {
+                continue;
+            }
 
 			/* 过滤注解非表字段属性 */
-			TableField tableField = field.getAnnotation(TableField.class);
-			if (tableField == null || tableField.exist()) {
-				result.add(field);
-			}
-		}
+            TableField tableField = field.getAnnotation(TableField.class);
+            if (tableField == null || tableField.exist()) {
+                result.add(field);
+            }
+        }
 
 		/* 处理父类字段 */
-		Class<?> superClass = clazz.getSuperclass();
-		if (superClass.equals(Object.class)) {
-			return result;
-		}
-		result.addAll(getAllFields(superClass));
-		return result;
-	}
+        Class<?> superClass = clazz.getSuperclass();
+        if (superClass.equals(Object.class)) {
+            return result;
+        }
+        result.addAll(getAllFields(superClass));
+        return result;
+    }
+
+    /**
+     * 缓存sqlSessionFactory
+     *
+     * @param sqlSessionFactory
+     * @return
+     */
+    public static void cacheSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
+        Collection<TableInfo> values = tableInfoCache.values();
+        for (TableInfo tableInfo : values) {
+            if (null == tableInfo.getSqlSessionFactory()) {
+                tableInfo.setSqlSessionFactory(sqlSessionFactory);
+            }
+
+
+        }
+    }
 
 }

+ 2 - 2
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/RoleMapper.java

@@ -1,12 +1,12 @@
 package com.baomidou.mybatisplus.test.mysql;
 
-import com.baomidou.mybatisplus.mapper.AutoMapper;
+import com.baomidou.mybatisplus.mapper.BaseMapper;
 import com.baomidou.mybatisplus.test.mysql.entity.Role;
 
 /**
  * @author junyu
  * @Date 2016-09-09
  */
-public interface RoleMapper extends AutoMapper<Role> {
+public interface RoleMapper extends BaseMapper<Role> {
 
 }

+ 3 - 3
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/TestMapper.java

@@ -17,18 +17,18 @@ package com.baomidou.mybatisplus.test.mysql;
 
 import org.apache.ibatis.annotations.Insert;
 
-import com.baomidou.mybatisplus.mapper.AutoMapper;
+import com.baomidou.mybatisplus.mapper.BaseMapper;
 import com.baomidou.mybatisplus.test.mysql.entity.Test;
 
 /**
  * <p>
- * 继承 AutoMapper,就自动拥有CRUD方法
+ * 继承 BaseMapper,就自动拥有CRUD方法
  * </p>
  * 
  * @author Caratacus hubin
  * @Date 2016-09-25
  */
-public interface TestMapper extends AutoMapper<Test> {
+public interface TestMapper extends BaseMapper<Test> {
 
 	/**
 	 * 注解插入【测试】

+ 5 - 6
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/UserMapper.java

@@ -15,23 +15,22 @@
  */
 package com.baomidou.mybatisplus.test.mysql;
 
-import java.util.List;
-
+import com.baomidou.mybatisplus.mapper.BaseMapper;
+import com.baomidou.mybatisplus.test.mysql.entity.User;
 import org.apache.ibatis.annotations.Insert;
 import org.apache.ibatis.session.RowBounds;
 
-import com.baomidou.mybatisplus.mapper.AutoMapper;
-import com.baomidou.mybatisplus.test.mysql.entity.User;
+import java.util.List;
 
 /**
  * <p>
- * 继承 AutoMapper,就自动拥有CRUD方法
+ * 继承 BaseMapper,就自动拥有CRUD方法
  * </p>
  * 
  * @author hubin
  * @Date 2016-01-23
  */
-public interface UserMapper extends AutoMapper<User> {
+public interface UserMapper extends BaseMapper<User> {
 
 	/**
 	 * 用户列表,分页显示

+ 11 - 12
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/UserMapperTest.java

@@ -15,22 +15,21 @@
  */
 package com.baomidou.mybatisplus.test.mysql;
 
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.baomidou.mybatisplus.test.mysql.entity.Role;
-import org.apache.ibatis.session.SqlSession;
-import org.apache.ibatis.session.SqlSessionFactory;
-
 import com.baomidou.mybatisplus.MybatisSessionFactoryBuilder;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.baomidou.mybatisplus.plugins.Page;
 import com.baomidou.mybatisplus.plugins.pagination.Pagination;
+import com.baomidou.mybatisplus.test.mysql.entity.Role;
 import com.baomidou.mybatisplus.test.mysql.entity.User;
 import com.baomidou.mybatisplus.toolkit.IdWorker;
+import org.apache.ibatis.session.SqlSession;
+import org.apache.ibatis.session.SqlSessionFactory;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -66,7 +65,7 @@ public class UserMapperTest {
 
 		/*
          * 此处采用 MybatisSessionFactoryBuilder 构建
-		 * SqlSessionFactory,目的是引入AutoMapper功能
+		 * SqlSessionFactory,目的是引入BaseMapper功能
 		 */
         MybatisSessionFactoryBuilder mf = new MybatisSessionFactoryBuilder();
 
@@ -201,7 +200,7 @@ public class UserMapperTest {
          * 修改
          * </p>
          *
-         * updateById 是从 AutoMapper 中继承而来的,UserMapper.xml中并没有申明改sql
+         * updateById 是从 BaseMapper 中继承而来的,UserMapper.xml中并没有申明改sql
          *
          */
         rlt = userMapper.updateSelectiveById(new User(12L, "MybatisPlus"));

+ 4 - 3
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/entity/Test.java

@@ -15,8 +15,7 @@
  */
 package com.baomidou.mybatisplus.test.mysql.entity;
 
-import java.io.Serializable;
-
+import com.baomidou.mybatisplus.activerecord.Model;
 import com.baomidou.mybatisplus.annotations.TableField;
 import com.baomidou.mybatisplus.annotations.TableId;
 import com.baomidou.mybatisplus.annotations.TableName;
@@ -30,10 +29,11 @@ import com.baomidou.mybatisplus.annotations.TableName;
  * @Date 2016-09-25
  */
 @TableName("test")
-public class Test implements Serializable {
+public class Test extends Model<Test> {
 
 	@TableField(exist = false)
 	private static final long serialVersionUID = 1L;
+	public static final Test instance = new Test();
 
 	/** 主键 */
 	@TableId
@@ -65,4 +65,5 @@ public class Test implements Serializable {
 	public void setType(String type) {
 		this.type = type;
 	}
+
 }

+ 2 - 2
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/oracle/TestUserMapper.java

@@ -1,6 +1,6 @@
 package com.baomidou.mybatisplus.test.oracle;
 
-import com.baomidou.mybatisplus.mapper.CommonMapper;
+import com.baomidou.mybatisplus.mapper.BaseMapper;
 import com.baomidou.mybatisplus.test.oracle.entity.TestUser;
 
 /**
@@ -8,7 +8,7 @@ import com.baomidou.mybatisplus.test.oracle.entity.TestUser;
  * TestUser 表数据库控制层接口
  *
  */
-public interface TestUserMapper extends CommonMapper<TestUser> {
+public interface TestUserMapper extends BaseMapper<TestUser> {
 
 
 }

+ 7 - 8
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/oracle/TestUserMapperTest.java

@@ -15,17 +15,16 @@
  */
 package com.baomidou.mybatisplus.test.oracle;
 
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.ibatis.session.SqlSession;
-import org.apache.ibatis.session.SqlSessionFactory;
-
 import com.baomidou.mybatisplus.MybatisSessionFactoryBuilder;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.baomidou.mybatisplus.plugins.Page;
 import com.baomidou.mybatisplus.test.oracle.entity.TestUser;
+import org.apache.ibatis.session.SqlSession;
+import org.apache.ibatis.session.SqlSessionFactory;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * <p>
@@ -50,7 +49,7 @@ public class TestUserMapperTest {
 
 		/*
 		 * 此处采用 MybatisSessionFactoryBuilder 构建
-		 * SqlSessionFactory,目的是引入AutoMapper功能
+		 * SqlSessionFactory,目的是引入BaseMapper功能
 		 */
 		MybatisSessionFactoryBuilder mf = new MybatisSessionFactoryBuilder();
 

+ 1 - 1
mybatis-plus/src/test/resources/mysql-config.xml

@@ -84,7 +84,7 @@
 				<property name="driver" value="com.mysql.jdbc.Driver" />
 				<property name="url" value="jdbc:mysql://localhost:3306/mybatis-plus" />
 				<property name="username" value="root" />
-				<property name="password" value="123456" />
+				<property name="password" value="521" />
 			<!-- 
 				<property name="driver" value="${jdbc.driver}" />
 				<property name="url" value="${jdbc.url}" />