();
+ private boolean caseSensitive = false;
//开始的分隔符,例如mysql为`,sqlserver为[
- private String beginningDelimiter = "";
+ private String beginningDelimiter = "";
//结束的分隔符,例如mysql为`,sqlserver为]
- private String endingDelimiter = "";
+ private String endingDelimiter = "";
//数据库模式
- private String schema;
+ private String schema;
//注释生成器
private CommentGeneratorConfiguration commentCfg;
//强制生成注解
- private boolean forceAnnotation;
+ private boolean forceAnnotation;
public String getDelimiterName(String name) {
StringBuilder nameBuilder = new StringBuilder();
@@ -124,7 +124,7 @@ private void processEntityClass(TopLevelClass topLevelClass, IntrospectedTable i
|| StringUtility.stringHasValue(beginningDelimiter)
|| StringUtility.stringHasValue(endingDelimiter)) {
topLevelClass.addAnnotation("@Table(name = \"" + getDelimiterName(tableName) + "\")");
- } else if(forceAnnotation){
+ } else if (forceAnnotation) {
topLevelClass.addAnnotation("@Table(name = \"" + getDelimiterName(tableName) + "\")");
}
}
diff --git a/src/main/java/tk/mybatis/mapper/generator/TkMyBatis3Impl.java b/src/main/java/tk/mybatis/mapper/generator/TkMyBatis3Impl.java
index 144e58954..c074d6034 100644
--- a/src/main/java/tk/mybatis/mapper/generator/TkMyBatis3Impl.java
+++ b/src/main/java/tk/mybatis/mapper/generator/TkMyBatis3Impl.java
@@ -1,7 +1,30 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2014-2017 abel533@gmail.com
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
package tk.mybatis.mapper.generator;
import org.mybatis.generator.codegen.mybatis3.IntrospectedTableMyBatis3Impl;
-import org.mybatis.generator.codegen.mybatis3.IntrospectedTableMyBatis3SimpleImpl;
import java.text.MessageFormat;
diff --git a/src/main/java/tk/mybatis/mapper/generator/TkMyBatis3SimpleImpl.java b/src/main/java/tk/mybatis/mapper/generator/TkMyBatis3SimpleImpl.java
index 32ab56c43..455b1e247 100644
--- a/src/main/java/tk/mybatis/mapper/generator/TkMyBatis3SimpleImpl.java
+++ b/src/main/java/tk/mybatis/mapper/generator/TkMyBatis3SimpleImpl.java
@@ -1,3 +1,27 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2014-2017 abel533@gmail.com
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
package tk.mybatis.mapper.generator;
import org.mybatis.generator.codegen.mybatis3.IntrospectedTableMyBatis3SimpleImpl;
diff --git a/src/main/java/tk/mybatis/mapper/mapperhelper/EntityHelper.java b/src/main/java/tk/mybatis/mapper/mapperhelper/EntityHelper.java
index 10fc8a2d4..fa93e47d8 100644
--- a/src/main/java/tk/mybatis/mapper/mapperhelper/EntityHelper.java
+++ b/src/main/java/tk/mybatis/mapper/mapperhelper/EntityHelper.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/main/java/tk/mybatis/mapper/mapperhelper/FieldHelper.java b/src/main/java/tk/mybatis/mapper/mapperhelper/FieldHelper.java
index 6cdc845dc..f93aaeb4b 100644
--- a/src/main/java/tk/mybatis/mapper/mapperhelper/FieldHelper.java
+++ b/src/main/java/tk/mybatis/mapper/mapperhelper/FieldHelper.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/main/java/tk/mybatis/mapper/mapperhelper/MapperHelper.java b/src/main/java/tk/mybatis/mapper/mapperhelper/MapperHelper.java
index 4eb09ef29..1dffdc7b8 100644
--- a/src/main/java/tk/mybatis/mapper/mapperhelper/MapperHelper.java
+++ b/src/main/java/tk/mybatis/mapper/mapperhelper/MapperHelper.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -89,24 +89,6 @@ public MapperHelper(Properties properties) {
setProperties(properties);
}
- /**
- * 获取通用Mapper配置
- *
- * @return
- */
- public Config getConfig() {
- return config;
- }
-
- /**
- * 设置通用Mapper配置
- *
- * @param config
- */
- public void setConfig(Config config) {
- this.config = config;
- }
-
/**
* 通过通用Mapper接口获取对应的MapperTemplate
*
@@ -231,46 +213,6 @@ public boolean isExtendCommonMapper(Class> mapperInterface) {
return false;
}
- /**
- * 重新设置SqlSource
- *
- * 执行该方法前必须使用isMapperMethod判断,否则msIdCache会空
- *
- * @param ms
- */
- public void setSqlSource(MappedStatement ms) {
- MapperTemplate mapperTemplate = msIdCache.get(ms.getId());
- try {
- if (mapperTemplate != null) {
- mapperTemplate.setSqlSource(ms);
- }
- } catch (Exception e) {
- throw new MapperException(e);
- }
- }
-
- /**
- * 配置属性
- *
- * @param properties
- */
- public void setProperties(Properties properties) {
- config.setProperties(properties);
- //注册通用接口
- String mapper = null;
- if (properties != null) {
- mapper = properties.getProperty("mappers");
- }
- if (StringUtil.isNotEmpty(mapper)) {
- String[] mappers = mapper.split(",");
- for (String mapperClass : mappers) {
- if (mapperClass.length() > 0) {
- registerMapper(mapperClass);
- }
- }
- }
- }
-
/**
* 如果当前注册的接口为空,自动注册默认接口
*/
@@ -315,4 +257,62 @@ public void processConfiguration(Configuration configuration, Class> mapperInt
}
}
+ /**
+ * 获取通用Mapper配置
+ *
+ * @return
+ */
+ public Config getConfig() {
+ return config;
+ }
+
+ /**
+ * 设置通用Mapper配置
+ *
+ * @param config
+ */
+ public void setConfig(Config config) {
+ this.config = config;
+ }
+
+ /**
+ * 配置属性
+ *
+ * @param properties
+ */
+ public void setProperties(Properties properties) {
+ config.setProperties(properties);
+ //注册通用接口
+ String mapper = null;
+ if (properties != null) {
+ mapper = properties.getProperty("mappers");
+ }
+ if (StringUtil.isNotEmpty(mapper)) {
+ String[] mappers = mapper.split(",");
+ for (String mapperClass : mappers) {
+ if (mapperClass.length() > 0) {
+ registerMapper(mapperClass);
+ }
+ }
+ }
+ }
+
+ /**
+ * 重新设置SqlSource
+ *
+ * 执行该方法前必须使用isMapperMethod判断,否则msIdCache会空
+ *
+ * @param ms
+ */
+ public void setSqlSource(MappedStatement ms) {
+ MapperTemplate mapperTemplate = msIdCache.get(ms.getId());
+ try {
+ if (mapperTemplate != null) {
+ mapperTemplate.setSqlSource(ms);
+ }
+ } catch (Exception e) {
+ throw new MapperException(e);
+ }
+ }
+
}
\ No newline at end of file
diff --git a/src/main/java/tk/mybatis/mapper/mapperhelper/MapperTemplate.java b/src/main/java/tk/mybatis/mapper/mapperhelper/MapperTemplate.java
index e4eacadd7..2e38bd162 100644
--- a/src/main/java/tk/mybatis/mapper/mapperhelper/MapperTemplate.java
+++ b/src/main/java/tk/mybatis/mapper/mapperhelper/MapperTemplate.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -83,13 +83,6 @@ public void addMethodMap(String methodName, Method method) {
methodMap.put(methodName, method);
}
- public String getUUID() {
- return mapperHelper.getConfig().getUUID();
- }
-
- public String getIDENTITY() {
- return mapperHelper.getConfig().getIDENTITY();
- }
/**
* 获取IDENTITY值的表达式
*
@@ -99,17 +92,7 @@ public String getIDENTITY() {
public String getIDENTITY(EntityColumn column) {
return MessageFormat.format(mapperHelper.getConfig().getIDENTITY(), column.getSequenceName(), column.getColumn(), column.getProperty(), column.getTable().getName());
}
- public boolean isBEFORE() {
- return mapperHelper.getConfig().isBEFORE();
- }
- public boolean isNotEmpty() {
- return mapperHelper.getConfig().isNotEmpty();
- }
-
- public boolean isCheckExampleEntityClass() {
- return mapperHelper.getConfig().isCheckExampleEntityClass();
- }
/**
* 是否支持该通用方法
*
@@ -150,45 +133,6 @@ protected void setSqlSource(MappedStatement ms, SqlSource sqlSource) {
msObject.setValue("sqlSource", sqlSource);
}
- /**
- * 重新设置SqlSource
- *
- * @param ms
- * @throws java.lang.reflect.InvocationTargetException
- * @throws IllegalAccessException
- */
- public void setSqlSource(MappedStatement ms) throws Exception {
- if (this.mapperClass == getMapperClass(ms.getId())) {
- throw new MapperException("请不要配置或扫描通用Mapper接口类:" + this.mapperClass);
- }
- Method method = methodMap.get(getMethodName(ms));
- try {
- //第一种,直接操作ms,不需要返回值
- if (method.getReturnType() == Void.TYPE) {
- method.invoke(this, ms);
- }
- //第二种,返回SqlNode
- else if (SqlNode.class.isAssignableFrom(method.getReturnType())) {
- SqlNode sqlNode = (SqlNode) method.invoke(this, ms);
- DynamicSqlSource dynamicSqlSource = new DynamicSqlSource(ms.getConfiguration(), sqlNode);
- setSqlSource(ms, dynamicSqlSource);
- }
- //第三种,返回xml形式的sql字符串
- else if (String.class.equals(method.getReturnType())) {
- String xmlSql = (String) method.invoke(this, ms);
- SqlSource sqlSource = createSqlSource(ms, xmlSql);
- //替换原有的SqlSource
- setSqlSource(ms, sqlSource);
- } else {
- throw new MapperException("自定义Mapper方法返回类型错误,可选的返回类型为void,SqlNode,String三种!");
- }
- } catch (IllegalAccessException e) {
- throw new MapperException(e);
- } catch (InvocationTargetException e) {
- throw new MapperException(e.getTargetException() != null ? e.getTargetException() : e);
- }
- }
-
/**
* 通过xmlSql创建sqlSource
*
@@ -278,4 +222,63 @@ protected String tableName(Class> entityClass) {
return entityTable.getName();
}
+ public String getIDENTITY() {
+ return mapperHelper.getConfig().getIDENTITY();
+ }
+
+ public String getUUID() {
+ return mapperHelper.getConfig().getUUID();
+ }
+
+ public boolean isBEFORE() {
+ return mapperHelper.getConfig().isBEFORE();
+ }
+
+ public boolean isCheckExampleEntityClass() {
+ return mapperHelper.getConfig().isCheckExampleEntityClass();
+ }
+
+ public boolean isNotEmpty() {
+ return mapperHelper.getConfig().isNotEmpty();
+ }
+
+ /**
+ * 重新设置SqlSource
+ *
+ * @param ms
+ * @throws java.lang.reflect.InvocationTargetException
+ * @throws IllegalAccessException
+ */
+ public void setSqlSource(MappedStatement ms) throws Exception {
+ if (this.mapperClass == getMapperClass(ms.getId())) {
+ throw new MapperException("请不要配置或扫描通用Mapper接口类:" + this.mapperClass);
+ }
+ Method method = methodMap.get(getMethodName(ms));
+ try {
+ //第一种,直接操作ms,不需要返回值
+ if (method.getReturnType() == Void.TYPE) {
+ method.invoke(this, ms);
+ }
+ //第二种,返回SqlNode
+ else if (SqlNode.class.isAssignableFrom(method.getReturnType())) {
+ SqlNode sqlNode = (SqlNode) method.invoke(this, ms);
+ DynamicSqlSource dynamicSqlSource = new DynamicSqlSource(ms.getConfiguration(), sqlNode);
+ setSqlSource(ms, dynamicSqlSource);
+ }
+ //第三种,返回xml形式的sql字符串
+ else if (String.class.equals(method.getReturnType())) {
+ String xmlSql = (String) method.invoke(this, ms);
+ SqlSource sqlSource = createSqlSource(ms, xmlSql);
+ //替换原有的SqlSource
+ setSqlSource(ms, sqlSource);
+ } else {
+ throw new MapperException("自定义Mapper方法返回类型错误,可选的返回类型为void,SqlNode,String三种!");
+ }
+ } catch (IllegalAccessException e) {
+ throw new MapperException(e);
+ } catch (InvocationTargetException e) {
+ throw new MapperException(e.getTargetException() != null ? e.getTargetException() : e);
+ }
+ }
+
}
diff --git a/src/main/java/tk/mybatis/mapper/mapperhelper/SelectKeyGenerator.java b/src/main/java/tk/mybatis/mapper/mapperhelper/SelectKeyGenerator.java
index 18b6e85b3..68de7d4c0 100644
--- a/src/main/java/tk/mybatis/mapper/mapperhelper/SelectKeyGenerator.java
+++ b/src/main/java/tk/mybatis/mapper/mapperhelper/SelectKeyGenerator.java
@@ -1,17 +1,25 @@
-/**
- * Copyright 2009-2016 the original author or authors.
- *
- * 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.
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2014-2017 abel533@gmail.com
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
*/
package tk.mybatis.mapper.mapperhelper;
diff --git a/src/main/java/tk/mybatis/mapper/mapperhelper/SelectKeyHelper.java b/src/main/java/tk/mybatis/mapper/mapperhelper/SelectKeyHelper.java
index 4e57a95c9..40bfe16cf 100644
--- a/src/main/java/tk/mybatis/mapper/mapperhelper/SelectKeyHelper.java
+++ b/src/main/java/tk/mybatis/mapper/mapperhelper/SelectKeyHelper.java
@@ -1,3 +1,27 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2014-2017 abel533@gmail.com
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
package tk.mybatis.mapper.mapperhelper;
import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
diff --git a/src/main/java/tk/mybatis/mapper/mapperhelper/SqlHelper.java b/src/main/java/tk/mybatis/mapper/mapperhelper/SqlHelper.java
index c6f5d304c..d20ed4485 100644
--- a/src/main/java/tk/mybatis/mapper/mapperhelper/SqlHelper.java
+++ b/src/main/java/tk/mybatis/mapper/mapperhelper/SqlHelper.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/main/java/tk/mybatis/mapper/provider/ConditionProvider.java b/src/main/java/tk/mybatis/mapper/provider/ConditionProvider.java
index 88225f91d..2deb75c30 100644
--- a/src/main/java/tk/mybatis/mapper/provider/ConditionProvider.java
+++ b/src/main/java/tk/mybatis/mapper/provider/ConditionProvider.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/main/java/tk/mybatis/mapper/provider/EmptyProvider.java b/src/main/java/tk/mybatis/mapper/provider/EmptyProvider.java
index 57a660b0d..5a39e40a6 100644
--- a/src/main/java/tk/mybatis/mapper/provider/EmptyProvider.java
+++ b/src/main/java/tk/mybatis/mapper/provider/EmptyProvider.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/main/java/tk/mybatis/mapper/provider/ExampleProvider.java b/src/main/java/tk/mybatis/mapper/provider/ExampleProvider.java
index 3dc8186fe..579f87932 100644
--- a/src/main/java/tk/mybatis/mapper/provider/ExampleProvider.java
+++ b/src/main/java/tk/mybatis/mapper/provider/ExampleProvider.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/main/java/tk/mybatis/mapper/provider/IdsProvider.java b/src/main/java/tk/mybatis/mapper/provider/IdsProvider.java
index d896a938e..335368b98 100644
--- a/src/main/java/tk/mybatis/mapper/provider/IdsProvider.java
+++ b/src/main/java/tk/mybatis/mapper/provider/IdsProvider.java
@@ -1,3 +1,27 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2014-2017 abel533@gmail.com
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
package tk.mybatis.mapper.provider;
import org.apache.ibatis.mapping.MappedStatement;
diff --git a/src/main/java/tk/mybatis/mapper/provider/SpecialProvider.java b/src/main/java/tk/mybatis/mapper/provider/SpecialProvider.java
index a81a09647..00a373289 100644
--- a/src/main/java/tk/mybatis/mapper/provider/SpecialProvider.java
+++ b/src/main/java/tk/mybatis/mapper/provider/SpecialProvider.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,7 +26,6 @@
import org.apache.ibatis.mapping.MappedStatement;
import tk.mybatis.mapper.entity.EntityColumn;
-import tk.mybatis.mapper.entity.EntityTable;
import tk.mybatis.mapper.mapperhelper.EntityHelper;
import tk.mybatis.mapper.mapperhelper.MapperHelper;
import tk.mybatis.mapper.mapperhelper.MapperTemplate;
diff --git a/src/main/java/tk/mybatis/mapper/provider/SqlServerProvider.java b/src/main/java/tk/mybatis/mapper/provider/SqlServerProvider.java
index 98a2a147f..00ac27f1a 100644
--- a/src/main/java/tk/mybatis/mapper/provider/SqlServerProvider.java
+++ b/src/main/java/tk/mybatis/mapper/provider/SqlServerProvider.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/main/java/tk/mybatis/mapper/provider/base/BaseDeleteProvider.java b/src/main/java/tk/mybatis/mapper/provider/base/BaseDeleteProvider.java
index 2793e6d5e..09788fd60 100644
--- a/src/main/java/tk/mybatis/mapper/provider/base/BaseDeleteProvider.java
+++ b/src/main/java/tk/mybatis/mapper/provider/base/BaseDeleteProvider.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/main/java/tk/mybatis/mapper/provider/base/BaseInsertProvider.java b/src/main/java/tk/mybatis/mapper/provider/base/BaseInsertProvider.java
index 49f99dd7c..a53136347 100644
--- a/src/main/java/tk/mybatis/mapper/provider/base/BaseInsertProvider.java
+++ b/src/main/java/tk/mybatis/mapper/provider/base/BaseInsertProvider.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/main/java/tk/mybatis/mapper/provider/base/BaseSelectProvider.java b/src/main/java/tk/mybatis/mapper/provider/base/BaseSelectProvider.java
index e9445c0e3..9a7bfbb2a 100644
--- a/src/main/java/tk/mybatis/mapper/provider/base/BaseSelectProvider.java
+++ b/src/main/java/tk/mybatis/mapper/provider/base/BaseSelectProvider.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/main/java/tk/mybatis/mapper/provider/base/BaseUpdateProvider.java b/src/main/java/tk/mybatis/mapper/provider/base/BaseUpdateProvider.java
index f30c62509..4a47bc195 100644
--- a/src/main/java/tk/mybatis/mapper/provider/base/BaseUpdateProvider.java
+++ b/src/main/java/tk/mybatis/mapper/provider/base/BaseUpdateProvider.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/main/java/tk/mybatis/mapper/util/MsUtil.java b/src/main/java/tk/mybatis/mapper/util/MsUtil.java
index 5e8be467c..34a168f87 100644
--- a/src/main/java/tk/mybatis/mapper/util/MsUtil.java
+++ b/src/main/java/tk/mybatis/mapper/util/MsUtil.java
@@ -1,3 +1,27 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2014-2017 abel533@gmail.com
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
package tk.mybatis.mapper.util;
import org.apache.ibatis.mapping.MappedStatement;
diff --git a/src/main/java/tk/mybatis/mapper/util/OGNL.java b/src/main/java/tk/mybatis/mapper/util/OGNL.java
index b01093169..4d9d6cf8c 100644
--- a/src/main/java/tk/mybatis/mapper/util/OGNL.java
+++ b/src/main/java/tk/mybatis/mapper/util/OGNL.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/main/java/tk/mybatis/mapper/util/SimpleTypeUtil.java b/src/main/java/tk/mybatis/mapper/util/SimpleTypeUtil.java
index d678904c6..7c38b9701 100644
--- a/src/main/java/tk/mybatis/mapper/util/SimpleTypeUtil.java
+++ b/src/main/java/tk/mybatis/mapper/util/SimpleTypeUtil.java
@@ -1,3 +1,27 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2014-2017 abel533@gmail.com
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
package tk.mybatis.mapper.util;
import tk.mybatis.mapper.MapperException;
diff --git a/src/main/java/tk/mybatis/mapper/util/SqlReservedWords.java b/src/main/java/tk/mybatis/mapper/util/SqlReservedWords.java
index 5502bef82..43d4a0a0f 100644
--- a/src/main/java/tk/mybatis/mapper/util/SqlReservedWords.java
+++ b/src/main/java/tk/mybatis/mapper/util/SqlReservedWords.java
@@ -1,17 +1,25 @@
-/**
- * Copyright 2006-2017 the original author or authors.
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2014-2017 abel533@gmail.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
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
*
- * 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.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
*/
package tk.mybatis.mapper.util;
@@ -957,6 +965,12 @@ public class SqlReservedWords {
}
}
+ /**
+ * Utility class - no instances allowed.
+ */
+ private SqlReservedWords() {
+ }
+
public static boolean containsWord(String word) {
boolean rc;
@@ -968,10 +982,4 @@ public static boolean containsWord(String word) {
return rc;
}
-
- /**
- * Utility class - no instances allowed.
- */
- private SqlReservedWords() {
- }
}
diff --git a/src/main/java/tk/mybatis/mapper/util/StringUtil.java b/src/main/java/tk/mybatis/mapper/util/StringUtil.java
index 43855b518..3529397a4 100644
--- a/src/main/java/tk/mybatis/mapper/util/StringUtil.java
+++ b/src/main/java/tk/mybatis/mapper/util/StringUtil.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/main/java/tk/mybatis/spring/mapper/MapperFactoryBean.java b/src/main/java/tk/mybatis/spring/mapper/MapperFactoryBean.java
index 1a441e1e5..2fddffa58 100644
--- a/src/main/java/tk/mybatis/spring/mapper/MapperFactoryBean.java
+++ b/src/main/java/tk/mybatis/spring/mapper/MapperFactoryBean.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/main/java/tk/mybatis/spring/mapper/MapperScannerConfigurer.java b/src/main/java/tk/mybatis/spring/mapper/MapperScannerConfigurer.java
index a9c13bb73..3049d2c4f 100644
--- a/src/main/java/tk/mybatis/spring/mapper/MapperScannerConfigurer.java
+++ b/src/main/java/tk/mybatis/spring/mapper/MapperScannerConfigurer.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -37,30 +37,6 @@
public class MapperScannerConfigurer extends org.mybatis.spring.mapper.MapperScannerConfigurer {
private MapperHelper mapperHelper = new MapperHelper();
- public void setMarkerInterface(Class> superClass) {
- super.setMarkerInterface(superClass);
- if (Marker.class.isAssignableFrom(superClass)) {
- mapperHelper.registerMapper(superClass);
- }
- }
-
- public MapperHelper getMapperHelper() {
- return mapperHelper;
- }
-
- public void setMapperHelper(MapperHelper mapperHelper) {
- this.mapperHelper = mapperHelper;
- }
-
- /**
- * 属性注入
- *
- * @param properties
- */
- public void setProperties(Properties properties) {
- mapperHelper.setProperties(properties);
- }
-
/**
* 注册完成后,对MapperFactoryBean的类进行特殊处理
*
@@ -85,4 +61,28 @@ public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) {
}
}
}
+
+ public MapperHelper getMapperHelper() {
+ return mapperHelper;
+ }
+
+ public void setMapperHelper(MapperHelper mapperHelper) {
+ this.mapperHelper = mapperHelper;
+ }
+
+ public void setMarkerInterface(Class> superClass) {
+ super.setMarkerInterface(superClass);
+ if (Marker.class.isAssignableFrom(superClass)) {
+ mapperHelper.registerMapper(superClass);
+ }
+ }
+
+ /**
+ * 属性注入
+ *
+ * @param properties
+ */
+ public void setProperties(Properties properties) {
+ mapperHelper.setProperties(properties);
+ }
}
\ No newline at end of file
diff --git a/src/main/resources/META-INF/spring-devtools.properties b/src/main/resources/META-INF/spring-devtools.properties
index 6e2f184c1..614902fe3 100644
--- a/src/main/resources/META-INF/spring-devtools.properties
+++ b/src/main/resources/META-INF/spring-devtools.properties
@@ -1 +1,24 @@
+#
+# The MIT License (MIT)
+#
+# Copyright (c) 2014-2017 abel533@gmail.com
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
restart.include.mapper=/mapper-[\\w-\\.]+jar
\ No newline at end of file
diff --git a/src/test/java/tk/mybatis/mapper/entity/model/CountryExample.java b/src/test/java/tk/mybatis/mapper/entity/model/CountryExample.java
index 2aa51185a..0e2ce01c5 100644
--- a/src/test/java/tk/mybatis/mapper/entity/model/CountryExample.java
+++ b/src/test/java/tk/mybatis/mapper/entity/model/CountryExample.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -38,26 +38,6 @@ public CountryExample() {
oredCriteria = new ArrayList();
}
- public String getOrderByClause() {
- return orderByClause;
- }
-
- public void setOrderByClause(String orderByClause) {
- this.orderByClause = orderByClause;
- }
-
- public boolean isDistinct() {
- return distinct;
- }
-
- public void setDistinct(boolean distinct) {
- this.distinct = distinct;
- }
-
- public List getOredCriteria() {
- return oredCriteria;
- }
-
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
@@ -95,18 +75,6 @@ protected GeneratedCriteria() {
criteria = new ArrayList();
}
- public boolean isValid() {
- return criteria.size() > 0;
- }
-
- public List getAllCriteria() {
- return criteria;
- }
-
- public List getCriteria() {
- return criteria;
- }
-
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
@@ -327,6 +295,18 @@ public Criteria andCountrycodeNotBetween(String value1, String value2) {
addCriterion("countrycode not between", value1, value2, "countrycode");
return (Criteria) this;
}
+
+ public List getAllCriteria() {
+ return criteria;
+ }
+
+ public List getCriteria() {
+ return criteria;
+ }
+
+ public boolean isValid() {
+ return criteria.size() > 0;
+ }
}
public static class Criteria extends GeneratedCriteria {
@@ -393,20 +373,16 @@ public String getCondition() {
return condition;
}
- public Object getValue() {
- return value;
- }
-
public Object getSecondValue() {
return secondValue;
}
- public boolean isNoValue() {
- return noValue;
+ public String getTypeHandler() {
+ return typeHandler;
}
- public boolean isSingleValue() {
- return singleValue;
+ public Object getValue() {
+ return value;
}
public boolean isBetweenValue() {
@@ -417,8 +393,32 @@ public boolean isListValue() {
return listValue;
}
- public String getTypeHandler() {
- return typeHandler;
+ public boolean isNoValue() {
+ return noValue;
+ }
+
+ public boolean isSingleValue() {
+ return singleValue;
}
}
+
+ public String getOrderByClause() {
+ return orderByClause;
+ }
+
+ public void setOrderByClause(String orderByClause) {
+ this.orderByClause = orderByClause;
+ }
+
+ public List getOredCriteria() {
+ return oredCriteria;
+ }
+
+ public boolean isDistinct() {
+ return distinct;
+ }
+
+ public void setDistinct(boolean distinct) {
+ this.distinct = distinct;
+ }
}
\ No newline at end of file
diff --git a/src/test/java/tk/mybatis/mapper/generator/Generator.java b/src/test/java/tk/mybatis/mapper/generator/Generator.java
index 25e9ab0fc..549a20560 100644
--- a/src/test/java/tk/mybatis/mapper/generator/Generator.java
+++ b/src/test/java/tk/mybatis/mapper/generator/Generator.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/helper/CamelCaseTest.java b/src/test/java/tk/mybatis/mapper/helper/CamelCaseTest.java
index 8021cbe31..c55b85848 100644
--- a/src/test/java/tk/mybatis/mapper/helper/CamelCaseTest.java
+++ b/src/test/java/tk/mybatis/mapper/helper/CamelCaseTest.java
@@ -1,3 +1,27 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2014-2017 abel533@gmail.com
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
package tk.mybatis.mapper.helper;
import org.junit.Assert;
diff --git a/src/test/java/tk/mybatis/mapper/helper/FieldHelperTest.java b/src/test/java/tk/mybatis/mapper/helper/FieldHelperTest.java
index 60fd1b6f7..f07a83a67 100644
--- a/src/test/java/tk/mybatis/mapper/helper/FieldHelperTest.java
+++ b/src/test/java/tk/mybatis/mapper/helper/FieldHelperTest.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/helper/FieldTest.java b/src/test/java/tk/mybatis/mapper/helper/FieldTest.java
index f032a451a..19c51d7a0 100644
--- a/src/test/java/tk/mybatis/mapper/helper/FieldTest.java
+++ b/src/test/java/tk/mybatis/mapper/helper/FieldTest.java
@@ -1,3 +1,27 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2014-2017 abel533@gmail.com
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
package tk.mybatis.mapper.helper;
import org.junit.Test;
@@ -23,31 +47,6 @@
*/
public class FieldTest {
- // @Test
- public void test1() throws IntrospectionException {
- List fields = null;// = new ArrayList();
- processAllColumns(Country.class, fields, null);
- for (EntityField field : fields) {
- System.out.println(field.getName() + " - @Id:" + field.isAnnotationPresent(Id.class) + " - javaType:" + field.getJavaType());
- }
- System.out.println("======================================");
-
- fields = FieldHelper.getAll(Country.class);
- for (EntityField field : fields) {
- System.out.println(field.getName() + " - @Id:" + field.isAnnotationPresent(Id.class) + " - javaType:" + field.getJavaType());
- }
- System.out.println("======================================");
- }
-
- @Test
- public void test2() {
- List fields = _getProperties(Country.class);
- for (EntityField field : fields) {
- System.out.println(field.getName() + " - @Id:" + field.isAnnotationPresent(Id.class) + " - javaType:" + field.getJavaType());
- }
- System.out.println("======================================");
- }
-
/**
* 通过方法获取属性
*
@@ -151,4 +150,29 @@ private static void processAllColumns(Class> entityClass, List fi
}
processAllColumns(superClass, fieldList, _genericMap);
}
+
+ // @Test
+ public void test1() throws IntrospectionException {
+ List fields = null;// = new ArrayList();
+ processAllColumns(Country.class, fields, null);
+ for (EntityField field : fields) {
+ System.out.println(field.getName() + " - @Id:" + field.isAnnotationPresent(Id.class) + " - javaType:" + field.getJavaType());
+ }
+ System.out.println("======================================");
+
+ fields = FieldHelper.getAll(Country.class);
+ for (EntityField field : fields) {
+ System.out.println(field.getName() + " - @Id:" + field.isAnnotationPresent(Id.class) + " - javaType:" + field.getJavaType());
+ }
+ System.out.println("======================================");
+ }
+
+ @Test
+ public void test2() {
+ List fields = _getProperties(Country.class);
+ for (EntityField field : fields) {
+ System.out.println(field.getName() + " - @Id:" + field.isAnnotationPresent(Id.class) + " - javaType:" + field.getJavaType());
+ }
+ System.out.println("======================================");
+ }
}
diff --git a/src/test/java/tk/mybatis/mapper/hsqldb/HsqldbMapper.java b/src/test/java/tk/mybatis/mapper/hsqldb/HsqldbMapper.java
index 6a61f69a1..223e46c60 100644
--- a/src/test/java/tk/mybatis/mapper/hsqldb/HsqldbMapper.java
+++ b/src/test/java/tk/mybatis/mapper/hsqldb/HsqldbMapper.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/hsqldb/HsqldbProvider.java b/src/test/java/tk/mybatis/mapper/hsqldb/HsqldbProvider.java
index c0bb5fa76..395dc6d55 100644
--- a/src/test/java/tk/mybatis/mapper/hsqldb/HsqldbProvider.java
+++ b/src/test/java/tk/mybatis/mapper/hsqldb/HsqldbProvider.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/mapper/CachedCountryMapper.java b/src/test/java/tk/mybatis/mapper/mapper/CachedCountryMapper.java
index 977b3a11e..16b19a8ab 100644
--- a/src/test/java/tk/mybatis/mapper/mapper/CachedCountryMapper.java
+++ b/src/test/java/tk/mybatis/mapper/mapper/CachedCountryMapper.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/mapper/Country2Mapper.java b/src/test/java/tk/mybatis/mapper/mapper/Country2Mapper.java
index ba9791b1b..7030f704d 100644
--- a/src/test/java/tk/mybatis/mapper/mapper/Country2Mapper.java
+++ b/src/test/java/tk/mybatis/mapper/mapper/Country2Mapper.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/mapper/CountryIMapper.java b/src/test/java/tk/mybatis/mapper/mapper/CountryIMapper.java
index 14ba441e9..36f5c0c96 100644
--- a/src/test/java/tk/mybatis/mapper/mapper/CountryIMapper.java
+++ b/src/test/java/tk/mybatis/mapper/mapper/CountryIMapper.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/mapper/CountryJDBCMapper.java b/src/test/java/tk/mybatis/mapper/mapper/CountryJDBCMapper.java
index d5417600a..2f4c42b24 100644
--- a/src/test/java/tk/mybatis/mapper/mapper/CountryJDBCMapper.java
+++ b/src/test/java/tk/mybatis/mapper/mapper/CountryJDBCMapper.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/mapper/CountryMapper.java b/src/test/java/tk/mybatis/mapper/mapper/CountryMapper.java
index b13be2c67..0c80d3a23 100644
--- a/src/test/java/tk/mybatis/mapper/mapper/CountryMapper.java
+++ b/src/test/java/tk/mybatis/mapper/mapper/CountryMapper.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/mapper/CountryTMapper.java b/src/test/java/tk/mybatis/mapper/mapper/CountryTMapper.java
index c87128d4a..f244f36a3 100644
--- a/src/test/java/tk/mybatis/mapper/mapper/CountryTMapper.java
+++ b/src/test/java/tk/mybatis/mapper/mapper/CountryTMapper.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/mapper/CountryUMapper.java b/src/test/java/tk/mybatis/mapper/mapper/CountryUMapper.java
index 4305e5179..c9e3d0ff4 100644
--- a/src/test/java/tk/mybatis/mapper/mapper/CountryUMapper.java
+++ b/src/test/java/tk/mybatis/mapper/mapper/CountryUMapper.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/mapper/JDBCMapper.java b/src/test/java/tk/mybatis/mapper/mapper/JDBCMapper.java
index 477583680..01cbe82c6 100644
--- a/src/test/java/tk/mybatis/mapper/mapper/JDBCMapper.java
+++ b/src/test/java/tk/mybatis/mapper/mapper/JDBCMapper.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/mapper/MybatisHelper.java b/src/test/java/tk/mybatis/mapper/mapper/MybatisHelper.java
index 5bd1c9afc..d781c540a 100644
--- a/src/test/java/tk/mybatis/mapper/mapper/MybatisHelper.java
+++ b/src/test/java/tk/mybatis/mapper/mapper/MybatisHelper.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/mapper/UserInfoAbleMapper.java b/src/test/java/tk/mybatis/mapper/mapper/UserInfoAbleMapper.java
index 636db313a..951e20fd5 100644
--- a/src/test/java/tk/mybatis/mapper/mapper/UserInfoAbleMapper.java
+++ b/src/test/java/tk/mybatis/mapper/mapper/UserInfoAbleMapper.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/mapper/UserInfoMapMapper.java b/src/test/java/tk/mybatis/mapper/mapper/UserInfoMapMapper.java
index ffdcb97e7..2eec20554 100644
--- a/src/test/java/tk/mybatis/mapper/mapper/UserInfoMapMapper.java
+++ b/src/test/java/tk/mybatis/mapper/mapper/UserInfoMapMapper.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/mapper/UserInfoMapper.java b/src/test/java/tk/mybatis/mapper/mapper/UserInfoMapper.java
index f7e6522f3..6fb19022b 100644
--- a/src/test/java/tk/mybatis/mapper/mapper/UserInfoMapper.java
+++ b/src/test/java/tk/mybatis/mapper/mapper/UserInfoMapper.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/mapper/UserLogin2Mapper.java b/src/test/java/tk/mybatis/mapper/mapper/UserLogin2Mapper.java
index d0fd7028c..379181436 100644
--- a/src/test/java/tk/mybatis/mapper/mapper/UserLogin2Mapper.java
+++ b/src/test/java/tk/mybatis/mapper/mapper/UserLogin2Mapper.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/mapper/UserLoginMapper.java b/src/test/java/tk/mybatis/mapper/mapper/UserLoginMapper.java
index 97de7d325..403e37408 100644
--- a/src/test/java/tk/mybatis/mapper/mapper/UserLoginMapper.java
+++ b/src/test/java/tk/mybatis/mapper/mapper/UserLoginMapper.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/model/Country.java b/src/test/java/tk/mybatis/mapper/model/Country.java
index 9e376da5f..515f3e2d4 100644
--- a/src/test/java/tk/mybatis/mapper/model/Country.java
+++ b/src/test/java/tk/mybatis/mapper/model/Country.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -41,25 +41,14 @@
*/
public class Country extends Entity implements Serializable, IDynamicTableName {
private static final long serialVersionUID = -1626761012846137805L;
-
+ List list;
@Column
@ColumnType(jdbcType = JdbcType.VARCHAR, typeHandler = StringType2Handler.class)
private String countryname;
private String countrycode;
-
- List list;
-
@Transient
private String dynamicTableName123;
- public String getCountryname() {
- return countryname;
- }
-
- public void setCountryname(String countryname) {
- this.countryname = countryname;
- }
-
public String getCountrycode() {
return countrycode;
}
@@ -68,12 +57,12 @@ public void setCountrycode(String countrycode) {
this.countrycode = countrycode;
}
- public List getList() {
- return list;
+ public String getCountryname() {
+ return countryname;
}
- public void setList(List list) {
- this.list = list;
+ public void setCountryname(String countryname) {
+ this.countryname = countryname;
}
@Override
@@ -82,6 +71,14 @@ public String getDynamicTableName() {
return dynamicTableName123;
}
+ public List getList() {
+ return list;
+ }
+
+ public void setList(List list) {
+ this.list = list;
+ }
+
public void setDynamicTableName123(String dynamicTableName) {
this.dynamicTableName123 = dynamicTableName;
}
diff --git a/src/test/java/tk/mybatis/mapper/model/Country2.java b/src/test/java/tk/mybatis/mapper/model/Country2.java
index 72a552030..a1e55efa1 100644
--- a/src/test/java/tk/mybatis/mapper/model/Country2.java
+++ b/src/test/java/tk/mybatis/mapper/model/Country2.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -40,12 +40,21 @@ public class Country2 {
private String countryname;
private String countrycode;
- public Integer getId() {
- return id;
+ @Override
+ public String toString() {
+ return "Country{" +
+ "id=" + id +
+ ", countryname='" + countryname + '\'' +
+ ", countrycode='" + countrycode + '\'' +
+ '}';
}
- public void setId(Integer id) {
- this.id = id;
+ public String getCountrycode() {
+ return countrycode;
+ }
+
+ public void setCountrycode(String countrycode) {
+ this.countrycode = countrycode;
}
public String getCountryname() {
@@ -56,20 +65,11 @@ public void setCountryname(String countryname) {
this.countryname = countryname;
}
- public String getCountrycode() {
- return countrycode;
- }
-
- public void setCountrycode(String countrycode) {
- this.countrycode = countrycode;
+ public Integer getId() {
+ return id;
}
- @Override
- public String toString() {
- return "Country{" +
- "id=" + id +
- ", countryname='" + countryname + '\'' +
- ", countrycode='" + countrycode + '\'' +
- '}';
+ public void setId(Integer id) {
+ this.id = id;
}
}
diff --git a/src/test/java/tk/mybatis/mapper/model/CountryExample.java b/src/test/java/tk/mybatis/mapper/model/CountryExample.java
index 414a43260..69fdcab76 100644
--- a/src/test/java/tk/mybatis/mapper/model/CountryExample.java
+++ b/src/test/java/tk/mybatis/mapper/model/CountryExample.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -62,56 +62,6 @@ public CountryExample() {
oredCriteria = new ArrayList();
}
- /**
- * This method was generated by MyBatis Generator.
- * This method corresponds to the database table country
- *
- * @mbggenerated Sat Mar 07 11:52:52 CST 2015
- */
- public String getOrderByClause() {
- return orderByClause;
- }
-
- /**
- * This method was generated by MyBatis Generator.
- * This method corresponds to the database table country
- *
- * @mbggenerated Sat Mar 07 11:52:52 CST 2015
- */
- public void setOrderByClause(String orderByClause) {
- this.orderByClause = orderByClause;
- }
-
- /**
- * This method was generated by MyBatis Generator.
- * This method corresponds to the database table country
- *
- * @mbggenerated Sat Mar 07 11:52:52 CST 2015
- */
- public boolean isDistinct() {
- return distinct;
- }
-
- /**
- * This method was generated by MyBatis Generator.
- * This method corresponds to the database table country
- *
- * @mbggenerated Sat Mar 07 11:52:52 CST 2015
- */
- public void setDistinct(boolean distinct) {
- this.distinct = distinct;
- }
-
- /**
- * This method was generated by MyBatis Generator.
- * This method corresponds to the database table country
- *
- * @mbggenerated Sat Mar 07 11:52:52 CST 2015
- */
- public List getOredCriteria() {
- return oredCriteria;
- }
-
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table country
@@ -185,18 +135,6 @@ protected GeneratedCriteria() {
criteria = new ArrayList();
}
- public boolean isValid() {
- return criteria.size() > 0;
- }
-
- public List getAllCriteria() {
- return criteria;
- }
-
- public List getCriteria() {
- return criteria;
- }
-
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
@@ -417,6 +355,18 @@ public Criteria andCountrycodeNotBetween(String value1, String value2) {
addCriterion("countrycode not between", value1, value2, "countrycode");
return (Criteria) this;
}
+
+ public List getAllCriteria() {
+ return criteria;
+ }
+
+ public List getCriteria() {
+ return criteria;
+ }
+
+ public boolean isValid() {
+ return criteria.size() > 0;
+ }
}
/**
@@ -495,20 +445,16 @@ public String getCondition() {
return condition;
}
- public Object getValue() {
- return value;
- }
-
public Object getSecondValue() {
return secondValue;
}
- public boolean isNoValue() {
- return noValue;
+ public String getTypeHandler() {
+ return typeHandler;
}
- public boolean isSingleValue() {
- return singleValue;
+ public Object getValue() {
+ return value;
}
public boolean isBetweenValue() {
@@ -519,8 +465,62 @@ public boolean isListValue() {
return listValue;
}
- public String getTypeHandler() {
- return typeHandler;
+ public boolean isNoValue() {
+ return noValue;
}
+
+ public boolean isSingleValue() {
+ return singleValue;
+ }
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table country
+ *
+ * @mbggenerated Sat Mar 07 11:52:52 CST 2015
+ */
+ public String getOrderByClause() {
+ return orderByClause;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table country
+ *
+ * @mbggenerated Sat Mar 07 11:52:52 CST 2015
+ */
+ public void setOrderByClause(String orderByClause) {
+ this.orderByClause = orderByClause;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table country
+ *
+ * @mbggenerated Sat Mar 07 11:52:52 CST 2015
+ */
+ public List getOredCriteria() {
+ return oredCriteria;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table country
+ *
+ * @mbggenerated Sat Mar 07 11:52:52 CST 2015
+ */
+ public boolean isDistinct() {
+ return distinct;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table country
+ *
+ * @mbggenerated Sat Mar 07 11:52:52 CST 2015
+ */
+ public void setDistinct(boolean distinct) {
+ this.distinct = distinct;
}
}
\ No newline at end of file
diff --git a/src/test/java/tk/mybatis/mapper/model/CountryI.java b/src/test/java/tk/mybatis/mapper/model/CountryI.java
index d3a320b8a..e0e37a46b 100644
--- a/src/test/java/tk/mybatis/mapper/model/CountryI.java
+++ b/src/test/java/tk/mybatis/mapper/model/CountryI.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -44,12 +44,21 @@ public class CountryI {
private String countryname;
private String countrycode;
- public Integer getId() {
- return id;
+ @Override
+ public String toString() {
+ return "Country{" +
+ "id=" + id +
+ ", countryname='" + countryname + '\'' +
+ ", countrycode='" + countrycode + '\'' +
+ '}';
}
- public void setId(Integer id) {
- this.id = id;
+ public String getCountrycode() {
+ return countrycode;
+ }
+
+ public void setCountrycode(String countrycode) {
+ this.countrycode = countrycode;
}
public String getCountryname() {
@@ -60,20 +69,11 @@ public void setCountryname(String countryname) {
this.countryname = countryname;
}
- public String getCountrycode() {
- return countrycode;
- }
-
- public void setCountrycode(String countrycode) {
- this.countrycode = countrycode;
+ public Integer getId() {
+ return id;
}
- @Override
- public String toString() {
- return "Country{" +
- "id=" + id +
- ", countryname='" + countryname + '\'' +
- ", countrycode='" + countrycode + '\'' +
- '}';
+ public void setId(Integer id) {
+ this.id = id;
}
}
diff --git a/src/test/java/tk/mybatis/mapper/model/CountryJDBC.java b/src/test/java/tk/mybatis/mapper/model/CountryJDBC.java
index 7db1e90da..27e68fad5 100644
--- a/src/test/java/tk/mybatis/mapper/model/CountryJDBC.java
+++ b/src/test/java/tk/mybatis/mapper/model/CountryJDBC.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -43,12 +43,21 @@ public class CountryJDBC {
private String countrycode;
- public Integer getId() {
- return id;
+ @Override
+ public String toString() {
+ return "Country{" +
+ "id=" + id +
+ ", countryname='" + countryname + '\'' +
+ ", countrycode='" + countrycode + '\'' +
+ '}';
}
- public void setId(Integer id) {
- this.id = id;
+ public String getCountrycode() {
+ return countrycode;
+ }
+
+ public void setCountrycode(String countrycode) {
+ this.countrycode = countrycode;
}
public String getCountryname() {
@@ -59,20 +68,11 @@ public void setCountryname(String countryname) {
this.countryname = countryname;
}
- public String getCountrycode() {
- return countrycode;
- }
-
- public void setCountrycode(String countrycode) {
- this.countrycode = countrycode;
+ public Integer getId() {
+ return id;
}
- @Override
- public String toString() {
- return "Country{" +
- "id=" + id +
- ", countryname='" + countryname + '\'' +
- ", countrycode='" + countrycode + '\'' +
- '}';
+ public void setId(Integer id) {
+ this.id = id;
}
}
diff --git a/src/test/java/tk/mybatis/mapper/model/CountryT.java b/src/test/java/tk/mybatis/mapper/model/CountryT.java
index 3c376f104..1c76d7ed6 100644
--- a/src/test/java/tk/mybatis/mapper/model/CountryT.java
+++ b/src/test/java/tk/mybatis/mapper/model/CountryT.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -41,12 +41,21 @@ public class CountryT {
@Transient
private String countrycode;
- public Integer getId() {
- return id;
+ @Override
+ public String toString() {
+ return "Country{" +
+ "id=" + id +
+ ", countryname='" + countryname + '\'' +
+ ", countrycode='" + countrycode + '\'' +
+ '}';
}
- public void setId(Integer id) {
- this.id = id;
+ public String getCountrycode() {
+ return countrycode;
+ }
+
+ public void setCountrycode(String countrycode) {
+ this.countrycode = countrycode;
}
public String getCountryname() {
@@ -57,20 +66,11 @@ public void setCountryname(String countryname) {
this.countryname = countryname;
}
- public String getCountrycode() {
- return countrycode;
- }
-
- public void setCountrycode(String countrycode) {
- this.countrycode = countrycode;
+ public Integer getId() {
+ return id;
}
- @Override
- public String toString() {
- return "Country{" +
- "id=" + id +
- ", countryname='" + countryname + '\'' +
- ", countrycode='" + countrycode + '\'' +
- '}';
+ public void setId(Integer id) {
+ this.id = id;
}
}
diff --git a/src/test/java/tk/mybatis/mapper/model/CountryU.java b/src/test/java/tk/mybatis/mapper/model/CountryU.java
index b0e682292..37ead2513 100644
--- a/src/test/java/tk/mybatis/mapper/model/CountryU.java
+++ b/src/test/java/tk/mybatis/mapper/model/CountryU.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -41,12 +41,21 @@ public class CountryU {
private String countrycode;
- public Integer getId() {
- return id;
+ @Override
+ public String toString() {
+ return "Country{" +
+ "id=" + id +
+ ", countryname='" + countryname + '\'' +
+ ", countrycode='" + countrycode + '\'' +
+ '}';
}
- public void setId(Integer id) {
- this.id = id;
+ public String getCountrycode() {
+ return countrycode;
+ }
+
+ public void setCountrycode(String countrycode) {
+ this.countrycode = countrycode;
}
public String getCountryname() {
@@ -57,20 +66,11 @@ public void setCountryname(String countryname) {
this.countryname = countryname;
}
- public String getCountrycode() {
- return countrycode;
- }
-
- public void setCountrycode(String countrycode) {
- this.countrycode = countrycode;
+ public Integer getId() {
+ return id;
}
- @Override
- public String toString() {
- return "Country{" +
- "id=" + id +
- ", countryname='" + countryname + '\'' +
- ", countrycode='" + countrycode + '\'' +
- '}';
+ public void setId(Integer id) {
+ this.id = id;
}
}
diff --git a/src/test/java/tk/mybatis/mapper/model/Entity.java b/src/test/java/tk/mybatis/mapper/model/Entity.java
index 89a2d3d62..271760d68 100644
--- a/src/test/java/tk/mybatis/mapper/model/Entity.java
+++ b/src/test/java/tk/mybatis/mapper/model/Entity.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/model/UserInfo.java b/src/test/java/tk/mybatis/mapper/model/UserInfo.java
index 41639952b..d391f1ee6 100644
--- a/src/test/java/tk/mybatis/mapper/model/UserInfo.java
+++ b/src/test/java/tk/mybatis/mapper/model/UserInfo.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -47,44 +47,51 @@ public class UserInfo implements Serializable {
private String address;
private String tel;
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
+ @Override
+ public String toString() {
+ return "UserInfo{" +
+ "id=" + id +
+ ", username='" + username + '\'' +
+ ", password='" + password + '\'' +
+ ", usertype='" + usertype + '\'' +
+ ", realname='" + realname + '\'' +
+ ", qq='" + qq + '\'' +
+ ", email='" + email + '\'' +
+ ", address='" + address + '\'' +
+ ", tel='" + tel + '\'' +
+ '}';
}
- public String getUsername() {
- return username;
+ public String getAddress() {
+ return address;
}
- public void setUsername(String username) {
- this.username = username;
+ public void setAddress(String address) {
+ this.address = address;
}
- public String getPassword() {
- return password;
+ public String getEmail() {
+ return email;
}
- public void setPassword(String password) {
- this.password = password;
+ public void setEmail(String email) {
+ this.email = email;
}
- public String getUsertype() {
- return usertype;
+ public Integer getId() {
+ return id;
}
- public void setUsertype(String usertype) {
- this.usertype = usertype;
+ public void setId(Integer id) {
+ this.id = id;
}
- public String getRealname() {
- return realname;
+ public String getPassword() {
+ return password;
}
- public void setRealname(String realname) {
- this.realname = realname;
+ public void setPassword(String password) {
+ this.password = password;
}
public String getQq() {
@@ -95,20 +102,12 @@ public void setQq(String qq) {
this.qq = qq;
}
- public String getEmail() {
- return email;
- }
-
- public void setEmail(String email) {
- this.email = email;
- }
-
- public String getAddress() {
- return address;
+ public String getRealname() {
+ return realname;
}
- public void setAddress(String address) {
- this.address = address;
+ public void setRealname(String realname) {
+ this.realname = realname;
}
public String getTel() {
@@ -119,18 +118,19 @@ public void setTel(String tel) {
this.tel = tel;
}
- @Override
- public String toString() {
- return "UserInfo{" +
- "id=" + id +
- ", username='" + username + '\'' +
- ", password='" + password + '\'' +
- ", usertype='" + usertype + '\'' +
- ", realname='" + realname + '\'' +
- ", qq='" + qq + '\'' +
- ", email='" + email + '\'' +
- ", address='" + address + '\'' +
- ", tel='" + tel + '\'' +
- '}';
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getUsertype() {
+ return usertype;
+ }
+
+ public void setUsertype(String usertype) {
+ this.usertype = usertype;
}
}
diff --git a/src/test/java/tk/mybatis/mapper/model/UserInfoAble.java b/src/test/java/tk/mybatis/mapper/model/UserInfoAble.java
index ba86e4b96..31dba0f3e 100644
--- a/src/test/java/tk/mybatis/mapper/model/UserInfoAble.java
+++ b/src/test/java/tk/mybatis/mapper/model/UserInfoAble.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -45,20 +45,35 @@ public class UserInfoAble extends UserParent implements Serializable {
private String email;
private String tel;
- public Integer getId() {
- return id;
+ @Override
+ public String toString() {
+ return "UserInfo{" +
+ "id=" + id +
+ ", username='" + username + '\'' +
+ ", password='" + password + '\'' +
+ ", usertype='" + usertype + '\'' +
+ ", realname='" + realname + '\'' +
+ ", qq='" + qq + '\'' +
+ ", email='" + email + '\'' +
+ ", tel='" + tel + '\'' +
+ '}';
}
- public void setId(Integer id) {
- this.id = id;
+ public String getEmail() {
+ return email;
}
- public String getUsername() {
- return username;
+ @Column(insertable = false)
+ public void setEmail(String email) {
+ this.email = email;
}
- public void setUsername(String username) {
- this.username = username;
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
}
public String getPassword() {
@@ -69,12 +84,12 @@ public void setPassword(String password) {
this.password = password;
}
- public String getUsertype() {
- return usertype;
+ public String getQq() {
+ return qq;
}
- public void setUsertype(String usertype) {
- this.usertype = usertype;
+ public void setQq(String qq) {
+ this.qq = qq;
}
public String getRealname() {
@@ -85,42 +100,27 @@ public void setRealname(String realname) {
this.realname = realname;
}
- public String getQq() {
- return qq;
- }
-
- public void setQq(String qq) {
- this.qq = qq;
+ public String getTel() {
+ return tel;
}
- public String getEmail() {
- return email;
+ public void setTel(String tel) {
+ this.tel = tel;
}
- @Column(insertable = false)
- public void setEmail(String email) {
- this.email = email;
+ public String getUsername() {
+ return username;
}
- public String getTel() {
- return tel;
+ public void setUsername(String username) {
+ this.username = username;
}
- public void setTel(String tel) {
- this.tel = tel;
+ public String getUsertype() {
+ return usertype;
}
- @Override
- public String toString() {
- return "UserInfo{" +
- "id=" + id +
- ", username='" + username + '\'' +
- ", password='" + password + '\'' +
- ", usertype='" + usertype + '\'' +
- ", realname='" + realname + '\'' +
- ", qq='" + qq + '\'' +
- ", email='" + email + '\'' +
- ", tel='" + tel + '\'' +
- '}';
+ public void setUsertype(String usertype) {
+ this.usertype = usertype;
}
}
diff --git a/src/test/java/tk/mybatis/mapper/model/UserInfoMap.java b/src/test/java/tk/mybatis/mapper/model/UserInfoMap.java
index 8d9b6e650..851329204 100644
--- a/src/test/java/tk/mybatis/mapper/model/UserInfoMap.java
+++ b/src/test/java/tk/mybatis/mapper/model/UserInfoMap.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -44,6 +44,18 @@ public class UserInfoMap extends HashMap implements Serializable
private String userType;
private String realName;
+ @Override
+ public String toString() {
+ final StringBuffer sb = new StringBuffer("UserInfoMap{");
+ sb.append("id=").append(id);
+ sb.append(", userName='").append(getUserName()).append('\'');
+ sb.append(", password='").append(getPassword()).append('\'');
+ sb.append(", userType='").append(getUserType()).append('\'');
+ sb.append(", realName='").append(getRealName()).append('\'');
+ sb.append('}');
+ return sb.toString();
+ }
+
public Integer getId() {
return (Integer) get("id");
}
@@ -52,14 +64,6 @@ public void setId(Integer id) {
put("id", id);
}
- public String getUserName() {
- return get("userName") != null ? (String) get("userName") : null;
- }
-
- public void setUserName(String userName) {
- put("userName", userName);
- }
-
public String getPassword() {
return get("password") != null ? (String) get("password") : null;
}
@@ -68,14 +72,6 @@ public void setPassword(String password) {
put("password", password);
}
- public String getUserType() {
- return get("userType") != null ? (String) get("userType") : null;
- }
-
- public void setUserType(String userType) {
- put("userType", userType);
- }
-
public String getRealName() {
return get("realName") != null ? (String) get("realName") : null;
}
@@ -84,15 +80,19 @@ public void setRealName(String realName) {
put("realName", realName);
}
- @Override
- public String toString() {
- final StringBuffer sb = new StringBuffer("UserInfoMap{");
- sb.append("id=").append(id);
- sb.append(", userName='").append(getUserName()).append('\'');
- sb.append(", password='").append(getPassword()).append('\'');
- sb.append(", userType='").append(getUserType()).append('\'');
- sb.append(", realName='").append(getRealName()).append('\'');
- sb.append('}');
- return sb.toString();
+ public String getUserName() {
+ return get("userName") != null ? (String) get("userName") : null;
+ }
+
+ public void setUserName(String userName) {
+ put("userName", userName);
+ }
+
+ public String getUserType() {
+ return get("userType") != null ? (String) get("userType") : null;
+ }
+
+ public void setUserType(String userType) {
+ put("userType", userType);
}
}
diff --git a/src/test/java/tk/mybatis/mapper/model/UserLogin.java b/src/test/java/tk/mybatis/mapper/model/UserLogin.java
index 283e6b77a..bde7eb6f1 100644
--- a/src/test/java/tk/mybatis/mapper/model/UserLogin.java
+++ b/src/test/java/tk/mybatis/mapper/model/UserLogin.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -42,6 +42,16 @@ public class UserLogin {
private Date logindate;
private String loginip;
+ @Override
+ public String toString() {
+ return "UserLogin{" +
+ "logid=" + logid +
+ ", username='" + username + '\'' +
+ ", logindate=" + logindate +
+ ", loginip='" + loginip + '\'' +
+ '}';
+ }
+
public Integer getLogid() {
return logid;
}
@@ -50,14 +60,6 @@ public void setLogid(Integer logid) {
this.logid = logid;
}
- public String getUsername() {
- return username;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
public Date getLogindate() {
return logindate;
}
@@ -74,13 +76,11 @@ public void setLoginip(String loginip) {
this.loginip = loginip;
}
- @Override
- public String toString() {
- return "UserLogin{" +
- "logid=" + logid +
- ", username='" + username + '\'' +
- ", logindate=" + logindate +
- ", loginip='" + loginip + '\'' +
- '}';
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
}
}
diff --git a/src/test/java/tk/mybatis/mapper/model/UserLogin2.java b/src/test/java/tk/mybatis/mapper/model/UserLogin2.java
index e5053f051..747d3bf2b 100644
--- a/src/test/java/tk/mybatis/mapper/model/UserLogin2.java
+++ b/src/test/java/tk/mybatis/mapper/model/UserLogin2.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -35,14 +35,6 @@ public class UserLogin2 extends UserLogin2Key {
private Date logindate;
private String loginip;
- public String getLoginip() {
- return loginip;
- }
-
- public void setLoginip(String loginip) {
- this.loginip = loginip;
- }
-
public Date getLogindate() {
return logindate;
}
@@ -50,4 +42,12 @@ public Date getLogindate() {
public void setLogindate(Date logindate) {
this.logindate = logindate;
}
+
+ public String getLoginip() {
+ return loginip;
+ }
+
+ public void setLoginip(String loginip) {
+ this.loginip = loginip;
+ }
}
diff --git a/src/test/java/tk/mybatis/mapper/model/UserLogin2Key.java b/src/test/java/tk/mybatis/mapper/model/UserLogin2Key.java
index 549719444..353a77941 100644
--- a/src/test/java/tk/mybatis/mapper/model/UserLogin2Key.java
+++ b/src/test/java/tk/mybatis/mapper/model/UserLogin2Key.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -39,6 +39,14 @@ public class UserLogin2Key {
@Id
private String username;
+ @Override
+ public String toString() {
+ return "UserLogin2Key{" +
+ "logid=" + logid +
+ ", username='" + username + '\'' +
+ '}';
+ }
+
public Integer getLogid() {
return logid;
}
@@ -54,12 +62,4 @@ public String getUsername() {
public void setUsername(String username) {
this.username = username;
}
-
- @Override
- public String toString() {
- return "UserLogin2Key{" +
- "logid=" + logid +
- ", username='" + username + '\'' +
- '}';
- }
}
diff --git a/src/test/java/tk/mybatis/mapper/model/UserParent.java b/src/test/java/tk/mybatis/mapper/model/UserParent.java
index e4b91ee26..f52317aab 100644
--- a/src/test/java/tk/mybatis/mapper/model/UserParent.java
+++ b/src/test/java/tk/mybatis/mapper/model/UserParent.java
@@ -1,3 +1,27 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2014-2017 abel533@gmail.com
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
package tk.mybatis.mapper.model;
import javax.persistence.Column;
diff --git a/src/test/java/tk/mybatis/mapper/test/able/TestBasicAble.java b/src/test/java/tk/mybatis/mapper/test/able/TestBasicAble.java
index 6e2fdd103..ce403d981 100644
--- a/src/test/java/tk/mybatis/mapper/test/able/TestBasicAble.java
+++ b/src/test/java/tk/mybatis/mapper/test/able/TestBasicAble.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/country/TestCache.java b/src/test/java/tk/mybatis/mapper/test/country/TestCache.java
index f8024a158..b47c3674b 100644
--- a/src/test/java/tk/mybatis/mapper/test/country/TestCache.java
+++ b/src/test/java/tk/mybatis/mapper/test/country/TestCache.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/country/TestDeleteByPrimaryKey.java b/src/test/java/tk/mybatis/mapper/test/country/TestDeleteByPrimaryKey.java
index 647c70459..488931d52 100644
--- a/src/test/java/tk/mybatis/mapper/test/country/TestDeleteByPrimaryKey.java
+++ b/src/test/java/tk/mybatis/mapper/test/country/TestDeleteByPrimaryKey.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/country/TestExistsWithPrimaryKey.java b/src/test/java/tk/mybatis/mapper/test/country/TestExistsWithPrimaryKey.java
index 4be582183..635d0c7d2 100644
--- a/src/test/java/tk/mybatis/mapper/test/country/TestExistsWithPrimaryKey.java
+++ b/src/test/java/tk/mybatis/mapper/test/country/TestExistsWithPrimaryKey.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -31,9 +31,6 @@
import tk.mybatis.mapper.mapper.MybatisHelper;
import tk.mybatis.mapper.model.Country;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* 通过主键查询
*
diff --git a/src/test/java/tk/mybatis/mapper/test/country/TestInsert.java b/src/test/java/tk/mybatis/mapper/test/country/TestInsert.java
index e8b8e9dab..a7c6fe3a9 100644
--- a/src/test/java/tk/mybatis/mapper/test/country/TestInsert.java
+++ b/src/test/java/tk/mybatis/mapper/test/country/TestInsert.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/country/TestInsertSelective.java b/src/test/java/tk/mybatis/mapper/test/country/TestInsertSelective.java
index 69d3dc01f..8c19b6ca1 100644
--- a/src/test/java/tk/mybatis/mapper/test/country/TestInsertSelective.java
+++ b/src/test/java/tk/mybatis/mapper/test/country/TestInsertSelective.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/country/TestSelect.java b/src/test/java/tk/mybatis/mapper/test/country/TestSelect.java
index 81d834601..5b35751ea 100644
--- a/src/test/java/tk/mybatis/mapper/test/country/TestSelect.java
+++ b/src/test/java/tk/mybatis/mapper/test/country/TestSelect.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/country/TestSelectAll.java b/src/test/java/tk/mybatis/mapper/test/country/TestSelectAll.java
index 85b8ab84a..df1beb83a 100644
--- a/src/test/java/tk/mybatis/mapper/test/country/TestSelectAll.java
+++ b/src/test/java/tk/mybatis/mapper/test/country/TestSelectAll.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/country/TestSelectByPrimaryKey.java b/src/test/java/tk/mybatis/mapper/test/country/TestSelectByPrimaryKey.java
index ba83be9fb..17ecbec1c 100644
--- a/src/test/java/tk/mybatis/mapper/test/country/TestSelectByPrimaryKey.java
+++ b/src/test/java/tk/mybatis/mapper/test/country/TestSelectByPrimaryKey.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/country/TestSelectCount.java b/src/test/java/tk/mybatis/mapper/test/country/TestSelectCount.java
index 23a8af81f..e911966fb 100644
--- a/src/test/java/tk/mybatis/mapper/test/country/TestSelectCount.java
+++ b/src/test/java/tk/mybatis/mapper/test/country/TestSelectCount.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/country/TestSelectOne.java b/src/test/java/tk/mybatis/mapper/test/country/TestSelectOne.java
index e0a0d63c7..06ce9ce78 100644
--- a/src/test/java/tk/mybatis/mapper/test/country/TestSelectOne.java
+++ b/src/test/java/tk/mybatis/mapper/test/country/TestSelectOne.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/country/TestUpdateByPrimaryKey.java b/src/test/java/tk/mybatis/mapper/test/country/TestUpdateByPrimaryKey.java
index 16d9d81f7..ee9b6ba28 100644
--- a/src/test/java/tk/mybatis/mapper/test/country/TestUpdateByPrimaryKey.java
+++ b/src/test/java/tk/mybatis/mapper/test/country/TestUpdateByPrimaryKey.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/country/TestUpdateByPrimaryKeySelective.java b/src/test/java/tk/mybatis/mapper/test/country/TestUpdateByPrimaryKeySelective.java
index bfca3bb99..dcd786fd9 100644
--- a/src/test/java/tk/mybatis/mapper/test/country/TestUpdateByPrimaryKeySelective.java
+++ b/src/test/java/tk/mybatis/mapper/test/country/TestUpdateByPrimaryKeySelective.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/country2/TestInsert.java b/src/test/java/tk/mybatis/mapper/test/country2/TestInsert.java
index c9ac50d66..4ca6101b1 100644
--- a/src/test/java/tk/mybatis/mapper/test/country2/TestInsert.java
+++ b/src/test/java/tk/mybatis/mapper/test/country2/TestInsert.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/country2/TestInsertSelective.java b/src/test/java/tk/mybatis/mapper/test/country2/TestInsertSelective.java
index 2b1120b31..af6d133ef 100644
--- a/src/test/java/tk/mybatis/mapper/test/country2/TestInsertSelective.java
+++ b/src/test/java/tk/mybatis/mapper/test/country2/TestInsertSelective.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -24,7 +24,6 @@
package tk.mybatis.mapper.test.country2;
-import org.apache.ibatis.exceptions.PersistenceException;
import org.apache.ibatis.session.SqlSession;
import org.junit.Assert;
import org.junit.Test;
diff --git a/src/test/java/tk/mybatis/mapper/test/example/TestDeleteByExample.java b/src/test/java/tk/mybatis/mapper/test/example/TestDeleteByExample.java
index 5c158974d..598ee646b 100644
--- a/src/test/java/tk/mybatis/mapper/test/example/TestDeleteByExample.java
+++ b/src/test/java/tk/mybatis/mapper/test/example/TestDeleteByExample.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/example/TestSelectByExample.java b/src/test/java/tk/mybatis/mapper/test/example/TestSelectByExample.java
index 510aa1398..e70d116ca 100644
--- a/src/test/java/tk/mybatis/mapper/test/example/TestSelectByExample.java
+++ b/src/test/java/tk/mybatis/mapper/test/example/TestSelectByExample.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -28,7 +28,6 @@
import org.apache.ibatis.type.StringTypeHandler;
import org.junit.Assert;
import org.junit.Test;
-import tk.mybatis.mapper.MapperException;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.entity.model.CountryExample;
import tk.mybatis.mapper.mapper.CountryMapper;
@@ -36,7 +35,10 @@
import tk.mybatis.mapper.model.Country;
import tk.mybatis.mapper.model.Country2;
-import java.util.*;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
/**
* @author liuzh
diff --git a/src/test/java/tk/mybatis/mapper/test/example/TestSelectCountByExample.java b/src/test/java/tk/mybatis/mapper/test/example/TestSelectCountByExample.java
index 6df125273..fa93e8376 100644
--- a/src/test/java/tk/mybatis/mapper/test/example/TestSelectCountByExample.java
+++ b/src/test/java/tk/mybatis/mapper/test/example/TestSelectCountByExample.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/example/TestUpdateByExample.java b/src/test/java/tk/mybatis/mapper/test/example/TestUpdateByExample.java
index 2a711df96..2a1dd8da4 100644
--- a/src/test/java/tk/mybatis/mapper/test/example/TestUpdateByExample.java
+++ b/src/test/java/tk/mybatis/mapper/test/example/TestUpdateByExample.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/example/TestUpdateByExampleSelective.java b/src/test/java/tk/mybatis/mapper/test/example/TestUpdateByExampleSelective.java
index 6ea3a426e..a3acda231 100644
--- a/src/test/java/tk/mybatis/mapper/test/example/TestUpdateByExampleSelective.java
+++ b/src/test/java/tk/mybatis/mapper/test/example/TestUpdateByExampleSelective.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/identity/TestIndentity.java b/src/test/java/tk/mybatis/mapper/test/identity/TestIndentity.java
index 22ee1c686..5c20ef335 100644
--- a/src/test/java/tk/mybatis/mapper/test/identity/TestIndentity.java
+++ b/src/test/java/tk/mybatis/mapper/test/identity/TestIndentity.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/ids/TestIds.java b/src/test/java/tk/mybatis/mapper/test/ids/TestIds.java
index aad41401e..073d3dc7e 100644
--- a/src/test/java/tk/mybatis/mapper/test/ids/TestIds.java
+++ b/src/test/java/tk/mybatis/mapper/test/ids/TestIds.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/jdbc/TestJDBC.java b/src/test/java/tk/mybatis/mapper/test/jdbc/TestJDBC.java
index d474756a9..f97448c92 100644
--- a/src/test/java/tk/mybatis/mapper/test/jdbc/TestJDBC.java
+++ b/src/test/java/tk/mybatis/mapper/test/jdbc/TestJDBC.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/mysql/TestMysql.java b/src/test/java/tk/mybatis/mapper/test/mysql/TestMysql.java
index fda274244..7bbd0e69d 100644
--- a/src/test/java/tk/mybatis/mapper/test/mysql/TestMysql.java
+++ b/src/test/java/tk/mybatis/mapper/test/mysql/TestMysql.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/othres/StyleTest.java b/src/test/java/tk/mybatis/mapper/test/othres/StyleTest.java
index 4aee93064..ee027e900 100644
--- a/src/test/java/tk/mybatis/mapper/test/othres/StyleTest.java
+++ b/src/test/java/tk/mybatis/mapper/test/othres/StyleTest.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/othres/TestDelimiter.java b/src/test/java/tk/mybatis/mapper/test/othres/TestDelimiter.java
index 8865edb3a..373556146 100644
--- a/src/test/java/tk/mybatis/mapper/test/othres/TestDelimiter.java
+++ b/src/test/java/tk/mybatis/mapper/test/othres/TestDelimiter.java
@@ -1,3 +1,27 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2014-2017 abel533@gmail.com
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
package tk.mybatis.mapper.test.othres;
import org.junit.Assert;
diff --git a/src/test/java/tk/mybatis/mapper/test/rowbounds/TestSelectRowBounds.java b/src/test/java/tk/mybatis/mapper/test/rowbounds/TestSelectRowBounds.java
index 901285e3e..d132f16af 100644
--- a/src/test/java/tk/mybatis/mapper/test/rowbounds/TestSelectRowBounds.java
+++ b/src/test/java/tk/mybatis/mapper/test/rowbounds/TestSelectRowBounds.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/transientc/TestTransient.java b/src/test/java/tk/mybatis/mapper/test/transientc/TestTransient.java
index 34916b6dc..a38b3a913 100644
--- a/src/test/java/tk/mybatis/mapper/test/transientc/TestTransient.java
+++ b/src/test/java/tk/mybatis/mapper/test/transientc/TestTransient.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/user/TestBasic.java b/src/test/java/tk/mybatis/mapper/test/user/TestBasic.java
index c91a70031..7829f05e4 100644
--- a/src/test/java/tk/mybatis/mapper/test/user/TestBasic.java
+++ b/src/test/java/tk/mybatis/mapper/test/user/TestBasic.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/user/TestDelete.java b/src/test/java/tk/mybatis/mapper/test/user/TestDelete.java
index 9d0afcbc0..5a41017e4 100644
--- a/src/test/java/tk/mybatis/mapper/test/user/TestDelete.java
+++ b/src/test/java/tk/mybatis/mapper/test/user/TestDelete.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/user/TestMap.java b/src/test/java/tk/mybatis/mapper/test/user/TestMap.java
index ea566b6ae..903f4b06a 100644
--- a/src/test/java/tk/mybatis/mapper/test/user/TestMap.java
+++ b/src/test/java/tk/mybatis/mapper/test/user/TestMap.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/user/TestUserLogin.java b/src/test/java/tk/mybatis/mapper/test/user/TestUserLogin.java
index 35f3409fe..3189f00cc 100644
--- a/src/test/java/tk/mybatis/mapper/test/user/TestUserLogin.java
+++ b/src/test/java/tk/mybatis/mapper/test/user/TestUserLogin.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/user/TestUserLogin2.java b/src/test/java/tk/mybatis/mapper/test/user/TestUserLogin2.java
index a4468e01b..5e3a4a015 100644
--- a/src/test/java/tk/mybatis/mapper/test/user/TestUserLogin2.java
+++ b/src/test/java/tk/mybatis/mapper/test/user/TestUserLogin2.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/test/uuid/TestUUID.java b/src/test/java/tk/mybatis/mapper/test/uuid/TestUUID.java
index 0b7119ad2..4e4efc87c 100644
--- a/src/test/java/tk/mybatis/mapper/test/uuid/TestUUID.java
+++ b/src/test/java/tk/mybatis/mapper/test/uuid/TestUUID.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/tk/mybatis/mapper/typehandler/StringType2Handler.java b/src/test/java/tk/mybatis/mapper/typehandler/StringType2Handler.java
index 3f1a7fd4d..1b1a588a3 100644
--- a/src/test/java/tk/mybatis/mapper/typehandler/StringType2Handler.java
+++ b/src/test/java/tk/mybatis/mapper/typehandler/StringType2Handler.java
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2016 abel533@gmail.com
+ * Copyright (c) 2014-2017 abel533@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/resources/CachedCountryMapper.xml b/src/test/resources/CachedCountryMapper.xml
index 87501a196..3babe808e 100644
--- a/src/test/resources/CachedCountryMapper.xml
+++ b/src/test/resources/CachedCountryMapper.xml
@@ -2,7 +2,7 @@
+当前时间:
+<#assign dateTime = .now>
+${dateTime?date}
+${dateTime?time}
+${dateTime?string["yyyy-MM-dd HH:mm:ss"]}
+
+所有配置的属性信息:
+<#list props?keys as key>
+${key} - ${props[key]}
+#list>
+
+<#list tableClassSet as tableClass>
+****************************************************************************************
+实体和表的信息:
+表名:${tableClass.tableName}
+变量名:${tableClass.variableName}
+小写名:${tableClass.lowerCaseName}
+类名:${tableClass.shortClassName}
+全名:${tableClass.fullClassName}
+包名:${tableClass.packageName}
+
+列的信息:
+=====================================
+ <#if tableClass.pkFields??>
+ 主键:
+ <#list tableClass.pkFields as field>
+ -------------------------------------
+ 列名:${field.columnName}
+ 列类型:${field.jdbcType}
+ 字段名:${field.fieldName}
+ 注释:${field.remarks}
+ 类型包名:${field.typePackage}
+ 类型短名:${field.shortTypeName}
+ 类型全名:${field.fullTypeName}
+ 是否主键:${field.identity?c}
+ 是否可空:${field.nullable?c}
+ 是否为BLOB列:${field.blobColumn?c}
+ 是否为String列:${field.stringColumn?c}
+ 是否为字符串列:${field.jdbcCharacterColumn?c}
+ 是否为日期列:${field.jdbcDateColumn?c}
+ 是否为时间列:${field.jdbcTimeColumn?c}
+ 是否为序列列:${field.sequenceColumn?c}
+ 列长度:${field.length?c}
+ 列精度:${field.scale}
+ #list>
+ #if>
+
+ <#if tableClass.baseFields??>
+ 基础列:
+ <#list tableClass.baseFields as field>
+ -------------------------------------
+ 列名:${field.columnName}
+ 列类型:${field.jdbcType}
+ 字段名:${field.fieldName}
+ 注释:${field.remarks}
+ 类型包名:${field.typePackage}
+ 类型短名:${field.shortTypeName}
+ 类型全名:${field.fullTypeName}
+ 是否主键:${field.identity?c}
+ 是否可空:${field.nullable?c}
+ 是否为BLOB列:${field.blobColumn?c}
+ 是否为String列:${field.stringColumn?c}
+ 是否为字符串列:${field.jdbcCharacterColumn?c}
+ 是否为日期列:${field.jdbcDateColumn?c}
+ 是否为时间列:${field.jdbcTimeColumn?c}
+ 是否为序列列:${field.sequenceColumn?c}
+ 列长度:${field.length?c}
+ 列精度:${field.scale}
+ #list>
+ #if>
+
+ <#if tableClass.blobFields??>
+ Blob列:
+ <#list tableClass.blobFields as field>
+ -------------------------------------
+ 列名:${field.columnName}
+ 列类型:${field.jdbcType}
+ 字段名:${field.fieldName}
+ 注释:${field.remarks}
+ 类型包名:${field.typePackage}
+ 类型短名:${field.shortTypeName}
+ 类型全名:${field.fullTypeName}
+ 是否主键:${field.identity?c}
+ 是否可空:${field.nullable?c}
+ 是否为BLOB列:${field.blobColumn?c}
+ 是否为String列:${field.stringColumn?c}
+ 是否为字符串列:${field.jdbcCharacterColumn?c}
+ 是否为日期列:${field.jdbcDateColumn?c}
+ 是否为时间列:${field.jdbcTimeColumn?c}
+ 是否为序列列:${field.sequenceColumn?c}
+ 列长度:${field.length?c}
+ 列精度:${field.scale}
+ #list>
+ #if>
+=====================================
+全部列:
+ <#if tableClass.allFields??>
+ 列名 - 字段名
+ <#list tableClass.allFields as field>
+ ${field.columnName} - ${field.fieldName}
+ #list>
+ #if>
+#list>
\ No newline at end of file
diff --git a/src/main/resources/generator/test-one.ftl b/src/main/resources/generator/test-one.ftl
new file mode 100644
index 000000000..2de6fe68d
--- /dev/null
+++ b/src/main/resources/generator/test-one.ftl
@@ -0,0 +1,103 @@
+目标package: ${package}
+
+当前时间:
+<#assign dateTime = .now>
+${dateTime?date}
+${dateTime?time}
+${dateTime?string["yyyy-MM-dd HH:mm:ss"]}
+
+所有配置的属性信息:
+<#list props?keys as key>
+${key} - ${props[key]}
+#list>
+
+实体和表的信息:
+表名:${tableClass.tableName}
+变量名:${tableClass.variableName}
+小写名:${tableClass.lowerCaseName}
+类名:${tableClass.shortClassName}
+全名:${tableClass.fullClassName}
+包名:${tableClass.packageName}
+
+列的信息:
+=====================================
+<#if tableClass.pkFields??>
+主键:
+ <#list tableClass.pkFields as field>
+ -------------------------------------
+ 列名:${field.columnName}
+ 列类型:${field.jdbcType}
+ 字段名:${field.fieldName}
+ 注释:${field.remarks}
+ 类型包名:${field.typePackage}
+ 类型短名:${field.shortTypeName}
+ 类型全名:${field.fullTypeName}
+ 是否主键:${field.identity?c}
+ 是否可空:${field.nullable?c}
+ 是否为BLOB列:${field.blobColumn?c}
+ 是否为String列:${field.stringColumn?c}
+ 是否为字符串列:${field.jdbcCharacterColumn?c}
+ 是否为日期列:${field.jdbcDateColumn?c}
+ 是否为时间列:${field.jdbcTimeColumn?c}
+ 是否为序列列:${field.sequenceColumn?c}
+ 列长度:${field.length?c}
+ 列精度:${field.scale}
+ #list>
+#if>
+
+<#if tableClass.baseFields??>
+基础列:
+ <#list tableClass.baseFields as field>
+ -------------------------------------
+ 列名:${field.columnName}
+ 列类型:${field.jdbcType}
+ 字段名:${field.fieldName}
+ 注释:${field.remarks}
+ 类型包名:${field.typePackage}
+ 类型短名:${field.shortTypeName}
+ 类型全名:${field.fullTypeName}
+ 是否主键:${field.identity?c}
+ 是否可空:${field.nullable?c}
+ 是否为BLOB列:${field.blobColumn?c}
+ 是否为String列:${field.stringColumn?c}
+ 是否为字符串列:${field.jdbcCharacterColumn?c}
+ 是否为日期列:${field.jdbcDateColumn?c}
+ 是否为时间列:${field.jdbcTimeColumn?c}
+ 是否为序列列:${field.sequenceColumn?c}
+ 列长度:${field.length?c}
+ 列精度:${field.scale}
+ #list>
+#if>
+
+<#if tableClass.blobFields??>
+Blob列:
+ <#list tableClass.blobFields as field>
+ -------------------------------------
+ 列名:${field.columnName}
+ 列类型:${field.jdbcType}
+ 字段名:${field.fieldName}
+ 注释:${field.remarks}
+ 类型包名:${field.typePackage}
+ 类型短名:${field.shortTypeName}
+ 类型全名:${field.fullTypeName}
+ 是否主键:${field.identity?c}
+ 是否可空:${field.nullable?c}
+ 是否为BLOB列:${field.blobColumn?c}
+ 是否为String列:${field.stringColumn?c}
+ 是否为字符串列:${field.jdbcCharacterColumn?c}
+ 是否为日期列:${field.jdbcDateColumn?c}
+ 是否为时间列:${field.jdbcTimeColumn?c}
+ 是否为序列列:${field.sequenceColumn?c}
+ 列长度:${field.length?c}
+ 列精度:${field.scale}
+ #list>
+#if>
+
+=====================================
+全部列:
+<#if tableClass.allFields??>
+列名 - 字段名
+ <#list tableClass.allFields as field>
+ ${field.columnName} - ${field.fieldName}
+ #list>
+#if>
\ No newline at end of file
diff --git a/src/test/resources/generator/generatorConfig.xml b/src/test/resources/generator/generatorConfig.xml
index 6a636d026..b78086815 100644
--- a/src/test/resources/generator/generatorConfig.xml
+++ b/src/test/resources/generator/generatorConfig.xml
@@ -27,33 +27,68 @@
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
+
-
-
-
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
+
-
-
-
-
+
+
\ No newline at end of file
From d55d722a6d66cd098c58e00ad8f1b925f27d9457 Mon Sep 17 00:00:00 2001
From: isea533
Date: Mon, 6 Nov 2017 22:18:28 +0800
Subject: [PATCH 087/428] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90?=
=?UTF-8?q?=E5=99=A8=E6=96=87=E6=A1=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
wiki/mapper3/11.CodeGenerator.md | 597 +++++++++++++++++++++++++++++++
1 file changed, 597 insertions(+)
create mode 100644 wiki/mapper3/11.CodeGenerator.md
diff --git a/wiki/mapper3/11.CodeGenerator.md b/wiki/mapper3/11.CodeGenerator.md
new file mode 100644
index 000000000..72c588eeb
--- /dev/null
+++ b/wiki/mapper3/11.CodeGenerator.md
@@ -0,0 +1,597 @@
+# 代码生成器文档
+
+代码生成器是基于 MBG 插件的,所以需要配合 MBG 使用。
+
+一个简单的 MBG 配置如下:
+
+```xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+```
+在这个配置中,我们只关注 `tk.mybatis.mapper.generator.TemplateFilePlugin`。
+
+## 基于模板的插件 `TemplateFilePlugin`
+
+这个插件中除了几个必备的属性外,还可以增加任意的属性,属性完全是为了给模板提供数据。
+
+先看一个基本完整的配置:
+
+```xml
+
+
+
+
+
+
+
+
+
+
+```
+
+下面介绍必备的属性。
+
+### 1. `targetProject`
+
+用于指定目标项目,一般是 `src/main/java` 或者 `src/main/resource` 这样的目录。
+还可以是 src/test/java` 或者 `src/test/resource` 这样的目录。
+
+在多模块项目中,还能通过相对路径指定为其他的目录,例如:
+
+```xml
+
+```
+
+**这个属性值有一个要求,就是目录必须存在,否则不会生成代码!**
+
+### 2. `targetPackage`
+
+用于指定包的部分,虽然是这个名字,实际上就是路径。
+
+**这个属性指定的路径如果不存在,就会自动创建。**
+
+这个属性的值可以为空,不管生成的是包还是路径,都需要安装包名方式来写。
+
+例如 `mapper.admin` 用于生成 `mapper/admin/` 目录,或者 `tk.mybatis.mapper` 生成包(本质上还是目录)。
+
+
+### 3. `templatePath`
+
+指定模板路径,可以是任意能够通过 ClassLoader 能够获取的位置,文件类型没有限制。
+
+例如示例中的 `generator/test-one.ftl`。
+
+这个属性还有一个特殊的地方,它还支持使用模板,就和下面的 `fileName` 一样,举个简单的使用场景。
+
+>你可能在生成前端代码的时候,希望将表对应的 JSP 生成在自己的一个目录中,此时可以配置为:
+>
+>``
+>
+>这里提供了一个 `lowerCaseName` 值,实际上通过模板语言提供的方法可以自动转换。
+>
+>模板中可以用到的属性,这里都能用,其他属性后面会介绍。
+
+**这个属性必须指定,否则不会生成代码!**
+
+通过这个路径也能看出来,配置一个插件只能根据模板在一个指定位置(targetProject 和 targetPackage 决定的目录)生成一个文件。
+
+
+### 4. `fileName`
+
+这个属性用于指定生成文件的名字,这个值支持使用模板,例如上面的 `${tableClass.shortClassName}Test.txt`,具体可用的属性会在后面介绍。
+
+**这个属性必须指定,否则不会生成代码!**
+
+### 5. `templateFormatter`
+
+**这个属性可选,默认使用基于 FreeMarker 的实现!**
+
+默认情况下,你需要添加下面的依赖:
+
+```xml
+
+ org.freemarker
+ freemarker
+ 2.3.23
+
+```
+
+默认的实现类为:`tk.mybatis.mapper.generator.formatter.FreemarkerTemplateFormatter`。
+
+这个类实现了两个接口 `TemplateFormatter, ListTemplateFormatter`。
+
+这俩接口分别对应下面 `singleMode` 参数值的 `true` 和 `false`。
+
+也就是一个表生成一个文件,或者多个表生成一个文件。
+
+对于一般情况下,都是第一种情况。但是在配置文件中,通过会有多个表对应的配置文件。
+
+如果你想使用其他模板引擎,可以自己实现上面的接口。
+
+### 6. `singleMode`
+
+上面已经提过,默认为 `true`。
+
+一个表生成一个文件时,可用属性可以参考 `generator/test-one.ftl`,表的属性在 `tableClass` 中。
+
+多个表生产一个文件时,可用属性可以参考 `generator/test-all.ftl`,所有表的属性在 `tableClassSet` 中,通过遍历可以获取单个的信息。
+
+### 7. 其他你需要的属性
+
+模板中需要的特殊信息都可以通过 `` 方法设置,在模板中直接使用这里定义的属性名来使用,后面例子的中的 `mapperSuffix` 就是这种属性。
+
+## `TemplateFilePlugin` 配置示例
+
+因为模板需要根据业务进行设计,所以这里只提供了两个简单的 mapper 目标和两个完整属性的示例模板。
+
+因为一个模板只能生成一类的文件,所以如果要生成多个不同的文件,就需要配置多个插件。
+
+>这种设计很灵活,因为自由度很高,所以代价就是配置的多。
+>
+>但是正常情况下,根据业务设计的一套模板基本是固定的,不会有太多变化,所以用起来并不麻烦。
+
+例如下面的示例:
+
+```xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+```
+
+前两个会生成 Dao 后缀的 Mapper 接口和 XML,其中有个针对性的参数 `mapperSuffix` 用于配置后缀,
+还有个 `mapperPackage` 在生成 XML 时获取接口的包名(因为和这里的 `targetPackage` 可以不同)。
+
+后两个插件用于演示所有可用的属性,而且是两种不同的模式。
+
+在表和实体上可用的所有属性如下:
+
+```
+特殊:targetPackage值在 ${package} 中。
+
+
+当前时间:
+<#assign dateTime = .now>
+日期:${dateTime?date}
+时间:${dateTime?time}
+格式化:${dateTime?string["yyyy-MM-dd HH:mm:ss"]}
+
+
+所有配置的属性信息:
+<#list props?keys as key>
+${key} - ${props[key]}
+#list>
+
+实体和表的信息:
+表名:${tableClass.tableName}
+变量名:${tableClass.variableName}
+小写名:${tableClass.lowerCaseName}
+类名:${tableClass.shortClassName}
+全名:${tableClass.fullClassName}
+包名:${tableClass.packageName}
+
+列的信息:
+=====================================
+<#if tableClass.pkFields??>
+主键:
+ <#list tableClass.pkFields as field>
+ -------------------------------------
+ 列名:${field.columnName}
+ 列类型:${field.jdbcType}
+ 字段名:${field.fieldName}
+ 注释:${field.remarks}
+ 类型包名:${field.typePackage}
+ 类型短名:${field.shortTypeName}
+ 类型全名:${field.fullTypeName}
+ 是否主键:${field.identity?c}
+ 是否可空:${field.nullable?c}
+ 是否为BLOB列:${field.blobColumn?c}
+ 是否为String列:${field.stringColumn?c}
+ 是否为字符串列:${field.jdbcCharacterColumn?c}
+ 是否为日期列:${field.jdbcDateColumn?c}
+ 是否为时间列:${field.jdbcTimeColumn?c}
+ 是否为序列列:${field.sequenceColumn?c}
+ 列长度:${field.length?c}
+ 列精度:${field.scale}
+ #list>
+#if>
+
+<#if tableClass.baseFields??>
+基础列:
+ <#list tableClass.baseFields as field>
+ -------------------------------------
+ 列名:${field.columnName}
+ 列类型:${field.jdbcType}
+ 字段名:${field.fieldName}
+ 注释:${field.remarks}
+ 类型包名:${field.typePackage}
+ 类型短名:${field.shortTypeName}
+ 类型全名:${field.fullTypeName}
+ 是否主键:${field.identity?c}
+ 是否可空:${field.nullable?c}
+ 是否为BLOB列:${field.blobColumn?c}
+ 是否为String列:${field.stringColumn?c}
+ 是否为字符串列:${field.jdbcCharacterColumn?c}
+ 是否为日期列:${field.jdbcDateColumn?c}
+ 是否为时间列:${field.jdbcTimeColumn?c}
+ 是否为序列列:${field.sequenceColumn?c}
+ 列长度:${field.length?c}
+ 列精度:${field.scale}
+ #list>
+#if>
+
+<#if tableClass.blobFields??>
+Blob列:
+ <#list tableClass.blobFields as field>
+ -------------------------------------
+ 列名:${field.columnName}
+ 列类型:${field.jdbcType}
+ 字段名:${field.fieldName}
+ 注释:${field.remarks}
+ 类型包名:${field.typePackage}
+ 类型短名:${field.shortTypeName}
+ 类型全名:${field.fullTypeName}
+ 是否主键:${field.identity?c}
+ 是否可空:${field.nullable?c}
+ 是否为BLOB列:${field.blobColumn?c}
+ 是否为String列:${field.stringColumn?c}
+ 是否为字符串列:${field.jdbcCharacterColumn?c}
+ 是否为日期列:${field.jdbcDateColumn?c}
+ 是否为时间列:${field.jdbcTimeColumn?c}
+ 是否为序列列:${field.sequenceColumn?c}
+ 列长度:${field.length?c}
+ 列精度:${field.scale}
+ #list>
+#if>
+
+=====================================
+全部列(包含了pk,base,blob 字段,可用的属性和上面的一样):
+<#if tableClass.allFields??>
+列名 - 字段名
+ <#list tableClass.allFields as field>
+ ${field.columnName} - ${field.fieldName}
+ #list>
+#if>
+```
+
+## 测试执行
+
+上面示例就是本项目的测试代码,在 `src/test/resources/generator/generatorConfig.xml` 中。
+
+还提供了一种 Java 编码方式运行的类,`src/test/java/` 中的 `tk.mybatis.mapper.generator.Generator`,配置上面 xml 中的数据库信息就可以生成。
+
+测试生成的**部分**结果如下。
+
+实体:
+```java
+@Table(name = "`user_info`")
+public class UserInfo {
+ @Id
+ @Column(name = "`Id`")
+ @GeneratedValue(generator = "JDBC")
+ private Integer id;
+```
+
+Dao:
+```java
+package test.mapper;
+
+import test.model.UserInfo;
+
+/**
+* 通用 Mapper 代码生成器
+*
+* @author mapper-generator
+*/
+public interface UserInfoDao extends tk.mybatis.mapper.common.Mapper {
+
+}
+```
+
+XML:
+```xml
+
+
+
+
+
+```
+
+test-one.ftl 生成的信息如下:
+```java
+目标package:
+
+当前时间:
+2017-11-6
+22:00:45
+2017-11-06 22:00:45
+
+所有配置的属性信息:
+targetPackage -
+templateFormatter - tk.mybatis.mapper.generator.formatter.FreemarkerTemplateFormatter
+templatePath - generator/test-one.ftl
+targetProject - src/test/resources
+fileName - ${tableClass.shortClassName}Test.txt
+
+实体和表的信息:
+表名:user_info
+变量名:userInfo
+小写名:userinfo
+类名:UserInfo
+全名:test.model.UserInfo
+包名:test.model
+
+列的信息:
+=====================================
+主键:
+ -------------------------------------
+ 列名:Id
+ 列类型:INTEGER
+ 字段名:id
+ 注释:
+ 类型包名:java.lang
+ 类型短名:Integer
+ 类型全名:java.lang.Integer
+ 是否主键:true
+ 是否可空:false
+ 是否为BLOB列:false
+ 是否为String列:false
+ 是否为字符串列:false
+ 是否为日期列:false
+ 是否为时间列:false
+ 是否为序列列:false
+ 列长度:10
+ 列精度:0
+
+基础列:
+ -------------------------------------
+ 列名:username
+ 列类型:VARCHAR
+ 字段名:username
+ 注释:用户名
+ 类型包名:java.lang
+ 类型短名:String
+ 类型全名:java.lang.String
+ 是否主键:false
+ 是否可空:false
+ 是否为BLOB列:false
+ 是否为String列:true
+ 是否为字符串列:true
+ 是否为日期列:false
+ 是否为时间列:false
+ 是否为序列列:false
+ 列长度:32
+ 列精度:0
+ -------------------------------------
+ 列名:password
+ 列类型:VARCHAR
+ 字段名:password
+ 注释:密码
+ 类型包名:java.lang
+ 类型短名:String
+ 类型全名:java.lang.String
+ 是否主键:false
+ 是否可空:true
+ 是否为BLOB列:false
+ 是否为String列:true
+ 是否为字符串列:true
+ 是否为日期列:false
+ 是否为时间列:false
+ 是否为序列列:false
+ 列长度:32
+ 列精度:0
+ -------------------------------------
+ 列名:usertype
+ 列类型:VARCHAR
+ 字段名:usertype
+ 注释:用户类型
+ 类型包名:java.lang
+ 类型短名:String
+ 类型全名:java.lang.String
+ 是否主键:false
+ 是否可空:true
+ 是否为BLOB列:false
+ 是否为String列:true
+ 是否为字符串列:true
+ 是否为日期列:false
+ 是否为时间列:false
+ 是否为序列列:false
+ 列长度:2
+ 列精度:0
+ -------------------------------------
+ 列名:enabled
+ 列类型:INTEGER
+ 字段名:enabled
+ 注释:是否可用
+ 类型包名:java.lang
+ 类型短名:Integer
+ 类型全名:java.lang.Integer
+ 是否主键:false
+ 是否可空:true
+ 是否为BLOB列:false
+ 是否为String列:false
+ 是否为字符串列:false
+ 是否为日期列:false
+ 是否为时间列:false
+ 是否为序列列:false
+ 列长度:10
+ 列精度:0
+ -------------------------------------
+ 列名:realname
+ 列类型:VARCHAR
+ 字段名:realname
+ 注释:真实姓名
+ 类型包名:java.lang
+ 类型短名:String
+ 类型全名:java.lang.String
+ 是否主键:false
+ 是否可空:true
+ 是否为BLOB列:false
+ 是否为String列:true
+ 是否为字符串列:true
+ 是否为日期列:false
+ 是否为时间列:false
+ 是否为序列列:false
+ 列长度:32
+ 列精度:0
+ -------------------------------------
+ 列名:qq
+ 列类型:VARCHAR
+ 字段名:qq
+ 注释:QQ
+ 类型包名:java.lang
+ 类型短名:String
+ 类型全名:java.lang.String
+ 是否主键:false
+ 是否可空:true
+ 是否为BLOB列:false
+ 是否为String列:true
+ 是否为字符串列:true
+ 是否为日期列:false
+ 是否为时间列:false
+ 是否为序列列:false
+ 列长度:14
+ 列精度:0
+ -------------------------------------
+ 列名:email
+ 列类型:VARCHAR
+ 字段名:email
+ 注释:
+ 类型包名:java.lang
+ 类型短名:String
+ 类型全名:java.lang.String
+ 是否主键:false
+ 是否可空:true
+ 是否为BLOB列:false
+ 是否为String列:true
+ 是否为字符串列:true
+ 是否为日期列:false
+ 是否为时间列:false
+ 是否为序列列:false
+ 列长度:100
+ 列精度:0
+ -------------------------------------
+ 列名:tel
+ 列类型:VARCHAR
+ 字段名:tel
+ 注释:联系电话
+ 类型包名:java.lang
+ 类型短名:String
+ 类型全名:java.lang.String
+ 是否主键:false
+ 是否可空:true
+ 是否为BLOB列:false
+ 是否为String列:true
+ 是否为字符串列:true
+ 是否为日期列:false
+ 是否为时间列:false
+ 是否为序列列:false
+ 列长度:255
+ 列精度:0
+
+Blob列:
+
+=====================================
+全部列:
+列名 - 字段名
+ Id - id
+ username - username
+ password - password
+ usertype - usertype
+ enabled - enabled
+ realname - realname
+ qq - qq
+ email - email
+ tel - tel
+```
+
+## 最后
+
+基础的代码生成器是很简单的,和 Java 拼字符串输出很像,这里只是使用了模板。
+
+几乎所有人都在 JSP 中用过的 EL 就是一种模板,可能你会 `自从 http://mybatis.tk 改版后,捐赠列表好久都没更新过了,如果你觉得这个插件和本文有用,可以小小的捐赠一笔。
+>
+>支付宝:
+>
+>
+>微信:
+>
From 7f0b2f2a497d1e76b4336bd334053e0bf45cf855 Mon Sep 17 00:00:00 2001
From: isea533
Date: Mon, 6 Nov 2017 22:29:01 +0800
Subject: [PATCH 088/428] =?UTF-8?q?=E5=A4=84=E7=90=86=E9=94=99=E5=88=AB?=
=?UTF-8?q?=E5=AD=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
wiki/mapper3/11.CodeGenerator.md | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/wiki/mapper3/11.CodeGenerator.md b/wiki/mapper3/11.CodeGenerator.md
index 72c588eeb..74418e6fc 100644
--- a/wiki/mapper3/11.CodeGenerator.md
+++ b/wiki/mapper3/11.CodeGenerator.md
@@ -75,7 +75,7 @@
### 1. `targetProject`
用于指定目标项目,一般是 `src/main/java` 或者 `src/main/resource` 这样的目录。
-还可以是 src/test/java` 或者 `src/test/resource` 这样的目录。
+还可以是 `src/test/java` 或者 `src/test/resource` 这样的目录。
在多模块项目中,还能通过相对路径指定为其他的目录,例如:
@@ -91,7 +91,7 @@
**这个属性指定的路径如果不存在,就会自动创建。**
-这个属性的值可以为空,不管生成的是包还是路径,都需要安装包名方式来写。
+这个属性的值可以为空,不管生成的是包还是路径,都需要按照包名方式来写。
例如 `mapper.admin` 用于生成 `mapper/admin/` 目录,或者 `tk.mybatis.mapper` 生成包(本质上还是目录)。
@@ -108,8 +108,6 @@
>
>``
>
->这里提供了一个 `lowerCaseName` 值,实际上通过模板语言提供的方法可以自动转换。
->
>模板中可以用到的属性,这里都能用,其他属性后面会介绍。
**这个属性必须指定,否则不会生成代码!**
@@ -145,7 +143,7 @@
也就是一个表生成一个文件,或者多个表生成一个文件。
-对于一般情况下,都是第一种情况。但是在配置文件中,通过会有多个表对应的配置文件。
+对于一般情况下,都是第一种情况。但是在配置文件中,可能会用到多个表的信息。
如果你想使用其他模板引擎,可以自己实现上面的接口。
@@ -155,7 +153,7 @@
一个表生成一个文件时,可用属性可以参考 `generator/test-one.ftl`,表的属性在 `tableClass` 中。
-多个表生产一个文件时,可用属性可以参考 `generator/test-all.ftl`,所有表的属性在 `tableClassSet` 中,通过遍历可以获取单个的信息。
+多个表生成一个文件时,可用属性可以参考 `generator/test-all.ftl`,所有表的属性在 `tableClassSet` 中,通过遍历可以获取单个的信息。
### 7. 其他你需要的属性
@@ -591,7 +589,9 @@ Blob列:
>自从 http://mybatis.tk 改版后,捐赠列表好久都没更新过了,如果你觉得这个插件和本文有用,可以小小的捐赠一笔。
>
>支付宝:
+>
>
>
>微信:
+>
>
From 3692f7d3a50e99017fccd1ea6a5b862b7902883e Mon Sep 17 00:00:00 2001
From: wuyi
Date: Mon, 6 Nov 2017 23:11:35 +0800
Subject: [PATCH 089/428] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=B8=8B=E5=88=92?=
=?UTF-8?q?=E7=BA=BF=E9=A3=8E=E6=A0=BC=E6=9B=BF=E6=8D=A2=E4=B8=BA=E9=A9=BC?=
=?UTF-8?q?=E5=B3=B0=E9=A3=8E=E6=A0=BC=E7=9A=84Pattern=E4=B8=BAStringUtil?=
=?UTF-8?q?=E7=9A=84=E9=9D=99=E6=80=81=E5=8F=98=E9=87=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/tk/mybatis/mapper/util/StringUtil.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/main/java/tk/mybatis/mapper/util/StringUtil.java b/src/main/java/tk/mybatis/mapper/util/StringUtil.java
index 3529397a4..87f8786aa 100644
--- a/src/main/java/tk/mybatis/mapper/util/StringUtil.java
+++ b/src/main/java/tk/mybatis/mapper/util/StringUtil.java
@@ -33,6 +33,7 @@
* Created by liuzh_3nofxnp on 2015/8/26.
*/
public class StringUtil {
+ private static Pattern UNDERLINE_TO_CAMELHUMP_PATTERN = Pattern.compile("_[a-z]");
/**
* 空
@@ -104,7 +105,7 @@ public static String camelhumpToUnderline(String str) {
* 将下划线风格替换为驼峰风格
*/
public static String underlineToCamelhump(String str) {
- Matcher matcher = Pattern.compile("_[a-z]").matcher(str);
+ Matcher matcher = UNDERLINE_TO_CAMELHUMP_PATTERN.matcher(str);
StringBuilder builder = new StringBuilder(str);
for (int i = 0; matcher.find(); i++) {
builder.replace(matcher.start() - i, matcher.end() - i, matcher.group().substring(1).toUpperCase());
From fe14f8320c23b78a7694c3a5adead00c451f1f6e Mon Sep 17 00:00:00 2001
From: isea533
Date: Sat, 11 Nov 2017 16:17:36 +0800
Subject: [PATCH 090/428] =?UTF-8?q?=E5=8F=91=E5=B8=83=203.4.5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 2 +-
wiki/Changelog.md | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 19491eb48..0bff0d778 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
tk.mybatis
mapper
- 3.4.5-SNAPSHOT
+ 3.4.5
jar
mapper
diff --git a/wiki/Changelog.md b/wiki/Changelog.md
index 561f5aacb..879480908 100644
--- a/wiki/Changelog.md
+++ b/wiki/Changelog.md
@@ -1,6 +1,6 @@
# 更新日志
-## 3.4.5 - 2017-11-05
+## 3.4.5 - 2017-11-11
- 插件增加一个 `` 属性配置,可以控制是否使用通用 Mapper 自带的 `MapperCommentGenerator`,用法如下:
```xml
@@ -12,6 +12,7 @@
```
+- 增加基于 MBG 的代码生成器插件,参考[使用文档](https://github.com/abel533/Mapper/blob/master/wiki/mapper3/11.CodeGenerator.md)。
## 3.4.4 - 2017-10-19
From 51d6b57f52ffef68cabf39991c2746619550d8d6 Mon Sep 17 00:00:00 2001
From: isea533
Date: Sun, 12 Nov 2017 13:20:41 +0800
Subject: [PATCH 091/428] =?UTF-8?q?=E5=A6=82=E9=9C=80=E5=8A=A0=E7=BE=A4?=
=?UTF-8?q?=EF=BC=8C=E8=AF=B7=E9=80=9A=E8=BF=87=20http://mybatis.tk=20?=
=?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=8C=89=E9=92=AE=E5=8A=A0=E7=BE=A4=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/README.md b/README.md
index a3f1b5d1b..60e27f7de 100644
--- a/README.md
+++ b/README.md
@@ -153,7 +153,6 @@ MyBatis 工具网站:[http://mybatis.tk](http://www.mybatis.tk)
作者邮箱: abel533@gmail.com
-Mybatis工具群:
-
+如需加群,请通过 http://mybatis.tk 首页按钮加群。
推荐使用Mybatis分页插件:[PageHelper分页插件](https://github.com/pagehelper/Mybatis-PageHelper)
\ No newline at end of file
From 822e21c7e8b4e1bcbf8a37180f2476900552b787 Mon Sep 17 00:00:00 2001
From: isea533
Date: Mon, 13 Nov 2017 11:15:56 +0800
Subject: [PATCH 092/428] update
---
wiki/Changelog.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/wiki/Changelog.md b/wiki/Changelog.md
index 879480908..6ec4b5710 100644
--- a/wiki/Changelog.md
+++ b/wiki/Changelog.md
@@ -13,6 +13,7 @@
```
- 增加基于 MBG 的代码生成器插件,参考[使用文档](https://github.com/abel533/Mapper/blob/master/wiki/mapper3/11.CodeGenerator.md)。
+- 设置下划线风格替换为驼峰风格的Pattern为StringUtil的静态变量(by [Ngone51](https://github.com/abel533/Mapper/commits?author=Ngone51))。
## 3.4.4 - 2017-10-19
From 3a2b446e30a37fc65dfe396f3aeaf62db0bfc21b Mon Sep 17 00:00:00 2001
From: isea533
Date: Mon, 13 Nov 2017 11:19:03 +0800
Subject: [PATCH 093/428] 3.4.6-SNAPSHOT
---
pom.xml | 2 +-
wiki/Changelog.md | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 0bff0d778..1cb4dab94 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
tk.mybatis
mapper
- 3.4.5
+ 3.4.6-SNAPSHOT
jar
mapper
diff --git a/wiki/Changelog.md b/wiki/Changelog.md
index 6ec4b5710..1c3222b14 100644
--- a/wiki/Changelog.md
+++ b/wiki/Changelog.md
@@ -1,5 +1,10 @@
# 更新日志
+## 3.4.6-SNAPSHOT
+
+- 设置下划线风格替换为驼峰风格的Pattern为StringUtil的静态变量(by [Ngone51](https://github.com/abel533/Mapper/commits?author=Ngone51))。
+
+
## 3.4.5 - 2017-11-11
- 插件增加一个 `` 属性配置,可以控制是否使用通用 Mapper 自带的 `MapperCommentGenerator`,用法如下:
@@ -13,7 +18,6 @@
```
- 增加基于 MBG 的代码生成器插件,参考[使用文档](https://github.com/abel533/Mapper/blob/master/wiki/mapper3/11.CodeGenerator.md)。
-- 设置下划线风格替换为驼峰风格的Pattern为StringUtil的静态变量(by [Ngone51](https://github.com/abel533/Mapper/commits?author=Ngone51))。
## 3.4.4 - 2017-10-19
From 76e46f345766749ef947af6baeeb62c1f6396efb Mon Sep 17 00:00:00 2001
From: Liuzh
Date: Mon, 13 Nov 2017 11:54:43 +0800
Subject: [PATCH 094/428] Update 11.CodeGenerator.md
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
解决文档中 templatePath 介绍错误的bug
---
wiki/mapper3/11.CodeGenerator.md | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/wiki/mapper3/11.CodeGenerator.md b/wiki/mapper3/11.CodeGenerator.md
index 74418e6fc..722840563 100644
--- a/wiki/mapper3/11.CodeGenerator.md
+++ b/wiki/mapper3/11.CodeGenerator.md
@@ -95,25 +95,23 @@
例如 `mapper.admin` 用于生成 `mapper/admin/` 目录,或者 `tk.mybatis.mapper` 生成包(本质上还是目录)。
-
-### 3. `templatePath`
-
-指定模板路径,可以是任意能够通过 ClassLoader 能够获取的位置,文件类型没有限制。
-
-例如示例中的 `generator/test-one.ftl`。
-
这个属性还有一个特殊的地方,它还支持使用模板,就和下面的 `fileName` 一样,举个简单的使用场景。
>你可能在生成前端代码的时候,希望将表对应的 JSP 生成在自己的一个目录中,此时可以配置为:
>
->``
+>``
>
>模板中可以用到的属性,这里都能用,其他属性后面会介绍。
-**这个属性必须指定,否则不会生成代码!**
-
通过这个路径也能看出来,配置一个插件只能根据模板在一个指定位置(targetProject 和 targetPackage 决定的目录)生成一个文件。
+### 3. `templatePath`
+
+指定模板路径,可以是任意能够通过 ClassLoader 能够获取的位置,文件类型没有限制。
+
+例如示例中的 `generator/test-one.ftl`。
+
+**这个属性必须指定,否则不会生成代码!**
### 4. `fileName`
From dbde609f949808ed3bc5df36466880aad01425ef Mon Sep 17 00:00:00 2001
From: Liuzh
Date: Mon, 13 Nov 2017 11:57:42 +0800
Subject: [PATCH 095/428] Update 11.CodeGenerator.md
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
targetPackage 可以是包形式或者路径形式
---
wiki/mapper3/11.CodeGenerator.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/wiki/mapper3/11.CodeGenerator.md b/wiki/mapper3/11.CodeGenerator.md
index 722840563..0e404e329 100644
--- a/wiki/mapper3/11.CodeGenerator.md
+++ b/wiki/mapper3/11.CodeGenerator.md
@@ -91,9 +91,9 @@
**这个属性指定的路径如果不存在,就会自动创建。**
-这个属性的值可以为空,不管生成的是包还是路径,都需要按照包名方式来写。
+这个属性的值可以为空。
-例如 `mapper.admin` 用于生成 `mapper/admin/` 目录,或者 `tk.mybatis.mapper` 生成包(本质上还是目录)。
+例如 `mapper/admin` 用于生成 `mapper/admin/` 目录,或者 `tk.mybatis.mapper` 生成包(本质上还是目录)。
这个属性还有一个特殊的地方,它还支持使用模板,就和下面的 `fileName` 一样,举个简单的使用场景。
From e3932268a28f44c42ab70be2656dab182e87614f Mon Sep 17 00:00:00 2001
From: wuyi5
Date: Fri, 10 Nov 2017 15:10:29 +0800
Subject: [PATCH 096/428] =?UTF-8?q?=E4=B8=BA=E6=96=B9=E6=B3=95selectProper?=
=?UTF-8?q?ties()=E6=B7=BB=E5=8A=A0=E6=8C=87=E5=AE=9A=E6=9F=A5=E8=AF=A2?=
=?UTF-8?q?=E5=AD=97=E6=AE=B5=E7=9A=84=E5=90=88=E6=B3=95=E6=80=A7=E6=A3=80?=
=?UTF-8?q?=E6=9F=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../tk/mybatis/mapper/entity/Example.java | 10 +++
.../test/example/TestSelectByExample.java | 85 ++++++++++++++++++-
2 files changed, 94 insertions(+), 1 deletion(-)
diff --git a/src/main/java/tk/mybatis/mapper/entity/Example.java b/src/main/java/tk/mybatis/mapper/entity/Example.java
index 250c9edc3..cd7b2a8a0 100644
--- a/src/main/java/tk/mybatis/mapper/entity/Example.java
+++ b/src/main/java/tk/mybatis/mapper/entity/Example.java
@@ -29,8 +29,10 @@
import org.apache.ibatis.type.TypeHandler;
import tk.mybatis.mapper.MapperException;
import tk.mybatis.mapper.mapperhelper.EntityHelper;
+import tk.mybatis.mapper.mapperhelper.FieldHelper;
import tk.mybatis.mapper.util.StringUtil;
+import javax.persistence.Transient;
import java.util.*;
/**
@@ -145,6 +147,14 @@ public Example selectProperties(String... properties) {
for (String property : properties) {
if (propertyMap.containsKey(property)) {
this.selectColumns.add(propertyMap.get(property).getColumn());
+ } else {
+ List fields = FieldHelper.getFields(entityClass);
+ for (EntityField field : fields) {
+ if (field.isAnnotationPresent(Transient.class) && property.equals(field.getName())) {
+ throw new MapperException("类 " + entityClass.getSimpleName() + " 的属性 \'" + property + "\' 被 @Transient 注释所修饰,不能指定为查询字段");
+ }
+ }
+ throw new MapperException("类 " + entityClass.getSimpleName() + " 不包含属性 \'" + property + "\'");
}
}
}
diff --git a/src/test/java/tk/mybatis/mapper/test/example/TestSelectByExample.java b/src/test/java/tk/mybatis/mapper/test/example/TestSelectByExample.java
index e70d116ca..fbce8163c 100644
--- a/src/test/java/tk/mybatis/mapper/test/example/TestSelectByExample.java
+++ b/src/test/java/tk/mybatis/mapper/test/example/TestSelectByExample.java
@@ -27,7 +27,10 @@
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.type.StringTypeHandler;
import org.junit.Assert;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import tk.mybatis.mapper.MapperException;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.entity.model.CountryExample;
import tk.mybatis.mapper.mapper.CountryMapper;
@@ -44,7 +47,8 @@
* @author liuzh
*/
public class TestSelectByExample {
-
+ @Rule
+ public ExpectedException exception = ExpectedException.none();
@Test
public void testSelectByExample() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
@@ -272,4 +276,83 @@ public void testOrderBy() {
}
}
+ /**
+ * 指定查询字段正确
+ */
+ @Test
+ public void testSelectPropertisCheckCorrect() {
+ SqlSession sqlSession = MybatisHelper.getSqlSession();
+ try {
+ CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
+ Example example = new Example(Country.class);
+ example.selectProperties(new String[]{"countryname"});
+ example.createCriteria().andEqualTo("id", 35);
+ List country1= mapper.selectByExample(example);
+ Assert.assertEquals(null, country1.get(0).getId());
+ Assert.assertEquals("China", country1.get(0).getCountryname());
+ Assert.assertEquals(null, country1.get(0).getCountrycode());
+ } finally {
+ sqlSession.close();
+ }
+ }
+
+ /**
+ * 指定查询字段拼写错误或不存在
+ */
+ @Test
+ public void testSelectPropertisCheckSpellWrong() {
+ exception.expect(MapperException.class);
+ exception.expectMessage("类 Country 不包含属性 'countrymame'");
+ SqlSession sqlSession = MybatisHelper.getSqlSession();
+ try {
+ CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
+ Example example = new Example(Country.class);
+ example.selectProperties(new String[]{"countrymame"});
+ example.createCriteria().andEqualTo("id", 35);
+ List country2 = mapper.selectByExample(example);
+ Assert.assertEquals(null, country2.get(0).getId());
+ Assert.assertEquals("China", country2.get(0).getCountryname());
+ Assert.assertEquals(null, country2.get(0).getCountrycode());
+ } finally {
+ sqlSession.close();
+ }
+ }
+
+ /**
+ * 指定查询字段为@Transient注释字段
+ */
+ @Test
+ public void testSelectPropertisCheckTransient1() {
+ exception.expect(MapperException.class);
+ exception.expectMessage("类 Country 的属性 'name' 被 @Transient 注释所修饰,不能指定为查询字段");
+ SqlSession sqlSession = MybatisHelper.getSqlSession();
+ try {
+ CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
+ Example example = new Example(Country.class);
+ example.selectProperties(new String[]{"name"});
+ example.createCriteria().andEqualTo("id", 35);
+ List country = mapper.selectByExample(example);
+ } finally {
+ sqlSession.close();
+ }
+ }
+
+ /**
+ * 指定查询字段为@Transient注释字段
+ */
+ @Test
+ public void testSelectPropertisCheckTransient2() {
+ exception.expect(MapperException.class);
+ exception.expectMessage("类 Country 的属性 'dynamicTableName123' 被 @Transient 注释所修饰,不能指定为查询字段");
+ SqlSession sqlSession = MybatisHelper.getSqlSession();
+ try {
+ CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
+ Example example = new Example(Country.class);
+ example.selectProperties(new String[]{"dynamicTableName123"});
+ example.createCriteria().andEqualTo("id", 35);
+ List country = mapper.selectByExample(example);
+ } finally {
+ sqlSession.close();
+ }
+ }
}
From a917a782d312d15545b6805cfe36a3c82d4df97c Mon Sep 17 00:00:00 2001
From: wuyi
Date: Sat, 11 Nov 2017 22:29:59 +0800
Subject: [PATCH 097/428] =?UTF-8?q?=E4=B8=BA=E6=96=B9=E6=B3=95excludePrope?=
=?UTF-8?q?rties()=E6=B7=BB=E5=8A=A0=E6=8C=87=E5=AE=9A=E6=9F=A5=E8=AF=A2?=
=?UTF-8?q?=E5=AD=97=E6=AE=B5=E7=9A=84=E5=90=88=E6=B3=95=E6=80=A7=E6=A3=80?=
=?UTF-8?q?=E6=9F=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../tk/mybatis/mapper/entity/Example.java | 10 ++--
.../test/example/TestSelectByExample.java | 47 +++++++++++++++++--
2 files changed, 47 insertions(+), 10 deletions(-)
diff --git a/src/main/java/tk/mybatis/mapper/entity/Example.java b/src/main/java/tk/mybatis/mapper/entity/Example.java
index cd7b2a8a0..8e8460494 100644
--- a/src/main/java/tk/mybatis/mapper/entity/Example.java
+++ b/src/main/java/tk/mybatis/mapper/entity/Example.java
@@ -127,6 +127,8 @@ public Example excludeProperties(String... properties) {
for (String property : properties) {
if (propertyMap.containsKey(property)) {
this.excludeColumns.add(propertyMap.get(property).getColumn());
+ } else {
+ throw new MapperException("类 " + entityClass.getSimpleName() + " 不包含属性 \'" + property + "\',或该属性被@Transient注释!");
}
}
}
@@ -148,13 +150,7 @@ public Example selectProperties(String... properties) {
if (propertyMap.containsKey(property)) {
this.selectColumns.add(propertyMap.get(property).getColumn());
} else {
- List fields = FieldHelper.getFields(entityClass);
- for (EntityField field : fields) {
- if (field.isAnnotationPresent(Transient.class) && property.equals(field.getName())) {
- throw new MapperException("类 " + entityClass.getSimpleName() + " 的属性 \'" + property + "\' 被 @Transient 注释所修饰,不能指定为查询字段");
- }
- }
- throw new MapperException("类 " + entityClass.getSimpleName() + " 不包含属性 \'" + property + "\'");
+ throw new MapperException("类 " + entityClass.getSimpleName() + " 不包含属性 \'" + property + "\',或该属性被@Transient注释!");
}
}
}
diff --git a/src/test/java/tk/mybatis/mapper/test/example/TestSelectByExample.java b/src/test/java/tk/mybatis/mapper/test/example/TestSelectByExample.java
index fbce8163c..dc35c638d 100644
--- a/src/test/java/tk/mybatis/mapper/test/example/TestSelectByExample.java
+++ b/src/test/java/tk/mybatis/mapper/test/example/TestSelectByExample.java
@@ -203,6 +203,8 @@ public void testSelectByExample4() {
@Test
public void testSelectColumnsByExample() {
+ exception.expect(MapperException.class);
+ exception.expectMessage("类 Country 不包含属性 'hehe',或该属性被@Transient注释!");
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
@@ -302,7 +304,7 @@ public void testSelectPropertisCheckCorrect() {
@Test
public void testSelectPropertisCheckSpellWrong() {
exception.expect(MapperException.class);
- exception.expectMessage("类 Country 不包含属性 'countrymame'");
+ exception.expectMessage("类 Country 不包含属性 'countrymame',或该属性被@Transient注释!");
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
@@ -324,7 +326,7 @@ public void testSelectPropertisCheckSpellWrong() {
@Test
public void testSelectPropertisCheckTransient1() {
exception.expect(MapperException.class);
- exception.expectMessage("类 Country 的属性 'name' 被 @Transient 注释所修饰,不能指定为查询字段");
+ exception.expectMessage("类 Country 不包含属性 'name',或该属性被@Transient注释!");
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
@@ -343,7 +345,7 @@ public void testSelectPropertisCheckTransient1() {
@Test
public void testSelectPropertisCheckTransient2() {
exception.expect(MapperException.class);
- exception.expectMessage("类 Country 的属性 'dynamicTableName123' 被 @Transient 注释所修饰,不能指定为查询字段");
+ exception.expectMessage("类 Country 不包含属性 'dynamicTableName123',或该属性被@Transient注释!");
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
@@ -355,4 +357,43 @@ public void testSelectPropertisCheckTransient2() {
sqlSession.close();
}
}
+
+ /**
+ * 指定排除的查询字段不存在或拼写错误
+ */
+ @Test
+ public void testExcludePropertisCheckWrongSpell() {
+ exception.expect(MapperException.class);
+ exception.expectMessage("类 Country 不包含属性 'countrymame',或该属性被@Transient注释!");
+ SqlSession sqlSession = MybatisHelper.getSqlSession();
+ try {
+ CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
+ Example example = new Example(Country.class);
+ example.excludeProperties(new String[]{"countrymame"});
+ example.createCriteria().andEqualTo("id", 35);
+ List country = mapper.selectByExample(example);
+ } finally {
+ sqlSession.close();
+ }
+ }
+
+ /**
+ * 指定排除的查询字段为@Transient注释字段
+ */
+ @Test
+ public void testExcludePropertisCheckTransient() {
+ exception.expect(MapperException.class);
+ exception.expectMessage("类 Country 不包含属性 'dynamicTableName123',或该属性被@Transient注释!");
+ SqlSession sqlSession = MybatisHelper.getSqlSession();
+ try {
+ CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
+ Example example = new Example(Country.class);
+ example.excludeProperties(new String[]{"dynamicTableName123"});
+ example.createCriteria().andEqualTo("id", 35);
+ List country = mapper.selectByExample(example);
+ } finally {
+ sqlSession.close();
+ }
+ }
+
}
From 7fc80d75632f7685838b76a8c96a1f6704e4ab6c Mon Sep 17 00:00:00 2001
From: isea533
Date: Sun, 26 Nov 2017 21:52:36 +0800
Subject: [PATCH 098/428] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E4=B8=8D=E9=9C=80?=
=?UTF-8?q?=E8=A6=81=E7=9A=84=20import=20=E7=B1=BB=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/tk/mybatis/mapper/entity/Example.java | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/main/java/tk/mybatis/mapper/entity/Example.java b/src/main/java/tk/mybatis/mapper/entity/Example.java
index 8e8460494..7309a7c19 100644
--- a/src/main/java/tk/mybatis/mapper/entity/Example.java
+++ b/src/main/java/tk/mybatis/mapper/entity/Example.java
@@ -29,10 +29,8 @@
import org.apache.ibatis.type.TypeHandler;
import tk.mybatis.mapper.MapperException;
import tk.mybatis.mapper.mapperhelper.EntityHelper;
-import tk.mybatis.mapper.mapperhelper.FieldHelper;
import tk.mybatis.mapper.util.StringUtil;
-import javax.persistence.Transient;
import java.util.*;
/**
From 680ff85611bfd0b6faf3a53f2c240535a5705bf7 Mon Sep 17 00:00:00 2001
From: wuyi
Date: Sun, 19 Nov 2017 23:49:38 +0800
Subject: [PATCH 099/428] =?UTF-8?q?=E7=94=A8builder=E6=9E=84=E5=BB=BAExamp?=
=?UTF-8?q?le?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../tk/mybatis/mapper/entity/Example.java | 202 ++++++++++++++
.../java/tk/mybatis/mapper/util/Sqls.java | 248 ++++++++++++++++++
.../test/example/TestExampleBuilder.java | 180 +++++++++++++
3 files changed, 630 insertions(+)
create mode 100644 src/main/java/tk/mybatis/mapper/util/Sqls.java
create mode 100644 src/test/java/tk/mybatis/mapper/test/example/TestExampleBuilder.java
diff --git a/src/main/java/tk/mybatis/mapper/entity/Example.java b/src/main/java/tk/mybatis/mapper/entity/Example.java
index 7309a7c19..ab53927d7 100644
--- a/src/main/java/tk/mybatis/mapper/entity/Example.java
+++ b/src/main/java/tk/mybatis/mapper/entity/Example.java
@@ -29,6 +29,7 @@
import org.apache.ibatis.type.TypeHandler;
import tk.mybatis.mapper.MapperException;
import tk.mybatis.mapper.mapperhelper.EntityHelper;
+import tk.mybatis.mapper.util.Sqls;
import tk.mybatis.mapper.util.StringUtil;
import java.util.*;
@@ -106,6 +107,20 @@ public Example(Class> entityClass, boolean exists, boolean notNull) {
this.ORDERBY = new OrderBy(this, propertyMap);
}
+
+ private Example(Builder builder) {
+ this.exists = builder.exists;
+ this.notNull = builder.notNull;
+ this.entityClass = builder.entityClass;
+ this.propertyMap = builder.propertyMap;
+ this.oredCriteria = builder.exampleCriterias;
+ this.ORDERBY = new OrderBy(this, propertyMap);
+ }
+
+ public static Builder builder(Class> entityClass) {
+ return new Builder(entityClass);
+ }
+
public OrderBy orderBy(String property) {
this.ORDERBY.orderBy(property);
return this.ORDERBY;
@@ -898,4 +913,191 @@ public void setCountProperty(String property) {
public void setTableName(String tableName) {
this.tableName = tableName;
}
+
+
+
+ public static class Builder {
+ private String orderByClause;
+
+ private boolean distinct;
+
+ private boolean exists;
+
+ private boolean notNull;
+
+ private boolean forUpdate;
+
+ //查询字段
+ private String[] selectColumns;
+
+ //排除的查询字段
+ private String[] excludeColumns;
+
+ private String countColumn;
+
+ private List sqlsCriteria;
+
+ private List exampleCriterias;
+ private final Class> entityClass;
+
+ protected EntityTable table;
+ //动态表名
+
+ //属性和列对应
+ protected Map propertyMap;
+
+ //动态表名
+ private String tableName;
+
+ public Builder(Class> entityClass) {
+ this(entityClass, true);
+ }
+
+ public Builder(Class> entityClass, boolean exists) {
+ this(entityClass, exists, false);
+ }
+
+ public Builder(Class> entityClass, boolean exists, boolean notNull) {
+ this.entityClass = entityClass;
+ this.exists = exists;
+ this.notNull = notNull;
+ this.table = EntityHelper.getEntityTable(entityClass);
+ this.propertyMap = table.getPropertyMap();
+ this.sqlsCriteria = new ArrayList(2);
+ }
+
+ public Builder setOrderByClause(String orderByClause) {
+ this.orderByClause = orderByClause;
+ return this;
+ }
+
+ public Builder distinct() {
+ return setDistinct(true);
+ }
+
+ public Builder setDistinct(boolean distinct) {
+ this.distinct = distinct;
+ return this;
+ }
+
+ public Builder forUpdate() {
+ return setForUpdate(true);
+ }
+
+ public Builder setForUpdate(boolean forUpdate) {
+ this.forUpdate = forUpdate;
+ return this;
+ }
+
+ public Builder selectDistinct(String... properties) {
+ this.selectColumns = properties;
+ this.distinct = distinct;
+ return this;
+ }
+
+ public Builder select(String... properties) {
+ this.selectColumns = properties;
+ return this;
+ }
+
+ public Builder notSelect(String... properties) {
+ this.excludeColumns = properties;
+ return this;
+ }
+
+ public Builder fromTable(String tableName) {
+ return setTableName(tableName);
+ }
+
+ public Builder setTableName(String tableName) {
+ this.tableName = tableName;
+ return this;
+ }
+ public Builder where(Sqls sqls) {
+ Sqls.Criteria criteria = sqls.getCriteria();
+ criteria.setAndOr("and");
+ this.sqlsCriteria.add(criteria);
+ return this;
+ }
+
+ public Builder andWhere(Sqls sqls) {
+ Sqls.Criteria criteria = sqls.getCriteria();
+ criteria.setAndOr("and");
+ this.sqlsCriteria.add(criteria);
+ return this;
+ }
+
+
+ public Builder orWhere(Sqls sqls) {
+ Sqls.Criteria criteria = sqls.getCriteria();
+ criteria.setAndOr("or");
+ this.sqlsCriteria.add(criteria);
+ return this;
+ }
+
+
+ public Example build() {
+ this.exampleCriterias = new ArrayList();
+ for (Sqls.Criteria criteria : sqlsCriteria) {
+ Example.Criteria exampleCriteria = new Example.Criteria(this.propertyMap, this.exists, this.notNull);
+ exampleCriteria.setAndOr(criteria.getAndOr());
+ for (Sqls.Criterion criterion : criteria.getCriterions()) {
+ String condition = criterion.getCondition();
+ String andOr = criterion.getAndOr();
+ String property = criterion.getProperty();
+ Object[] values = criterion.getValues();
+ transformCriterion(exampleCriteria, condition, property, values, andOr);
+ }
+ exampleCriterias.add(exampleCriteria);
+ }
+
+ Example innerExample = new Example(this);
+ innerExample.selectProperties(this.selectColumns);
+ innerExample.excludeProperties(this.excludeColumns);
+
+ return innerExample;
+ }
+
+ private void transformCriterion(Example.Criteria exampleCriteria, String condition, String property, Object[] values, String andOr) {
+ if (values.length == 0) {
+ if ("and".equals(andOr)) {
+ exampleCriteria.addCriterion(column(property) + " " + condition);
+ } else {
+ exampleCriteria.addOrCriterion(column(property) + " " + condition);
+ }
+ } else if (values.length == 1) {
+ if ("and".equals(andOr)) {
+ exampleCriteria.addCriterion(column(property) + " " + condition, values[0], property(property));
+ } else {
+ exampleCriteria.addOrCriterion(column(property) + " " + condition, values[0], property(property));
+ }
+ } else if (values.length == 2) {
+ if ("and".equals(andOr)) {
+ exampleCriteria.addCriterion(column(property) + " " + condition, values[0], values[1], property(property));
+ } else {
+ exampleCriteria.addOrCriterion(column(property) + " " + condition, values[0], values[1], property(property));
+ }
+ }
+ }
+
+ private String column(String property) {
+ if (propertyMap.containsKey(property)) {
+ return propertyMap.get(property).getColumn();
+ } else if (exists) {
+ throw new MapperException("当前实体类不包含名为" + property + "的属性!");
+ } else {
+ return null;
+ }
+ }
+
+ private String property(String property) {
+ if (propertyMap.containsKey(property)) {
+ return property;
+ } else if (exists) {
+ throw new MapperException("当前实体类不包含名为" + property + "的属性!");
+ } else {
+ return null;
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/src/main/java/tk/mybatis/mapper/util/Sqls.java b/src/main/java/tk/mybatis/mapper/util/Sqls.java
new file mode 100644
index 000000000..77f5f0c45
--- /dev/null
+++ b/src/main/java/tk/mybatis/mapper/util/Sqls.java
@@ -0,0 +1,248 @@
+package tk.mybatis.mapper.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author wuyi
+ * @date 2017/11/18
+ */
+public class Sqls {
+ private Criteria criteria;
+
+ private Sqls() {
+ this.criteria = new Criteria();
+ }
+
+ public static Sqls custom() {
+ return new Sqls();
+ }
+
+ public Criteria getCriteria() {
+ return criteria;
+ }
+
+ public Sqls andIsNull(String property) {
+ this.criteria.criterions.add(new Criterion(property, "is null", "and"));
+ return this;
+ }
+
+ public Sqls andIsNotNull(String property) {
+ this.criteria.criterions.add(new Criterion(property, "is not null", "and"));
+ return this;
+ }
+
+ public Sqls andEqualTo(String property, Object value) {
+ this.criteria.criterions.add(new Criterion(property, value, "=", "and"));
+ return this;
+ }
+
+ public Sqls andNotEqualTo(String property, Object value) {
+ this.criteria.criterions.add(new Criterion(property, value, "<>", "and"));
+ return this;
+ }
+
+ public Sqls andGreaterThan(String property, Object value) {
+ this.criteria.criterions.add(new Criterion(property, value, ">", "and"));
+ return this;
+ }
+
+ public Sqls andGreaterThanOrEqualTo(String property, Object value) {
+ this.criteria.criterions.add(new Criterion(property, value, ">=", "and"));
+ return this;
+ }
+
+
+ public Sqls andLessThan(String property, Object value) {
+ this.criteria.criterions.add(new Criterion(property, value, "<", "and"));
+ return this;
+ }
+
+ public Sqls andLessThanOrEqualTo(String property, Object value) {
+ this.criteria.criterions.add(new Criterion(property, value, "<=", "and"));
+ return this;
+ }
+
+ public Sqls andIn(String property, Iterable values) {
+ this.criteria.criterions.add(new Criterion(property, values, "in", "and"));
+ return this;
+ }
+
+ public Sqls andNotIn(String property, Iterable values) {
+ this.criteria.criterions.add(new Criterion(property, values, "not in", "and"));
+ return this;
+ }
+
+ public Sqls andBetween(String property, Object value1, Object value2) {
+ this.criteria.criterions.add(new Criterion(property, value1, value2, "between", "and"));
+ return this;
+ }
+
+ public Sqls andNotBetween(String property, Object value1, Object value2) {
+ this.criteria.criterions.add(new Criterion(property, value1, value2, "not between", "and"));
+ return this;
+ }
+
+ public Sqls andLike(String property, String value) {
+ this.criteria.criterions.add(new Criterion(property, value, "like", "and"));
+ return this;
+ }
+
+ public Sqls andNotLike(String property, String value) {
+ this.criteria.criterions.add(new Criterion(property, value, "not like", "and"));
+ return this;
+ }
+
+
+ public Sqls orIsNull(String property) {
+ this.criteria.criterions.add(new Criterion(property, "is null", "or"));
+ return this;
+ }
+
+ public Sqls orIsNotNull(String property) {
+ this.criteria.criterions.add(new Criterion(property, "is not null", "or"));
+ return this;
+ }
+
+
+ public Sqls orEqualTo(String property, Object value) {
+ this.criteria.criterions.add(new Criterion(property, value, "=", "or"));
+ return this;
+ }
+
+ public Sqls orNotEqualTo(String property, Object value) {
+ this.criteria.criterions.add(new Criterion(property, value, "<>", "or"));
+ return this;
+ }
+
+ public Sqls orGreaterThan(String property, Object value) {
+ this.criteria.criterions.add(new Criterion(property, value, ">", "or"));
+ return this;
+ }
+
+ public Sqls orGreaterThanOrEqualTo(String property, Object value) {
+ this.criteria.criterions.add(new Criterion(property, value, ">=", "or"));
+ return this;
+ }
+
+ public Sqls orLessThan(String property, Object value) {
+ this.criteria.criterions.add(new Criterion(property, value, "<", "or"));
+ return this;
+ }
+
+ public Sqls orLessThanOrEqualTo(String property, Object value) {
+ this.criteria.criterions.add(new Criterion(property, value, "<=", "or"));
+ return this;
+ }
+
+ public Sqls orIn(String property, Iterable values) {
+ this.criteria.criterions.add(new Criterion(property, values, "in", "or"));
+ return this;
+ }
+
+ public Sqls orNotIn(String property, Iterable values) {
+ this.criteria.criterions.add(new Criterion(property, values, "not in", "or"));
+ return this;
+ }
+
+ public Sqls orBetween(String property, Object value1, Object value2) {
+ this.criteria.criterions.add(new Criterion(property, value1, value2, "between", "or"));
+ return this;
+ }
+
+ public Sqls orNotBetween(String property, Object value1, Object value2) {
+ this.criteria.criterions.add(new Criterion(property, value1, value2, "not between", "or"));
+ return this;
+ }
+
+ public Sqls orLike(String property, String value) {
+ this.criteria.criterions.add(new Criterion(property, value, "like", "or"));
+ return this;
+ }
+
+ public Sqls orNotLike(String property, String value) {
+ this.criteria.criterions.add(new Criterion(property, value, "not like", "or"));
+ return this;
+ }
+
+ public static class Criteria {
+ private String andOr;
+ private List criterions;
+ public Criteria() {
+ this.criterions = new ArrayList(2);
+ }
+
+ public List getCriterions() {
+ return criterions;
+ }
+
+ public String getAndOr() {
+ return andOr;
+ }
+
+ public void setAndOr(String andOr) {
+ this.andOr = andOr;
+ }
+ }
+
+ public static class Criterion {
+ private String property;
+ private Object value;
+ private Object secondValue;
+ private String condition;
+ private String andOr;
+
+ public Criterion(String property, String condition, String andOr) {
+ this.property = property;
+ this.condition = condition;
+ this.andOr = andOr;
+ }
+
+
+ public Criterion(String property, Object value, String condition, String andOr) {
+ this.property = property;
+ this.value = value;
+ this.condition = condition;
+ this.andOr = andOr;
+ }
+
+ public Criterion(String property, Object value1, Object value2, String condition, String andOr) {
+ this.property = property;
+ this.value = value1;
+ this.secondValue = value2;
+ this.condition = condition;
+ this.andOr = andOr;
+ }
+
+ public String getProperty() {
+ return property;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public Object getSecondValue() {
+ return secondValue;
+ }
+
+ public Object[] getValues() {
+ if (value !=null) {
+ if (secondValue != null) {
+ return new Object[]{value, secondValue};
+ } else {
+ return new Object[] {value};
+ }
+ } else {
+ return new Object[]{};
+ }
+ }
+ public String getCondition() {
+ return condition;
+ }
+
+ public String getAndOr() {
+ return andOr;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/tk/mybatis/mapper/test/example/TestExampleBuilder.java b/src/test/java/tk/mybatis/mapper/test/example/TestExampleBuilder.java
new file mode 100644
index 000000000..a4ab35008
--- /dev/null
+++ b/src/test/java/tk/mybatis/mapper/test/example/TestExampleBuilder.java
@@ -0,0 +1,180 @@
+package tk.mybatis.mapper.test.example;
+
+import org.apache.ibatis.session.SqlSession;
+import org.junit.Assert;
+import org.junit.Test;
+import tk.mybatis.mapper.entity.Example;
+import tk.mybatis.mapper.mapper.CountryMapper;
+import tk.mybatis.mapper.mapper.MybatisHelper;
+import tk.mybatis.mapper.model.Country;
+import tk.mybatis.mapper.util.Sqls;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author wuyi
+ * @date 2017/11/18
+ */
+public class TestExampleBuilder {
+
+ @Test
+ public void testExampleBuilder() {
+ SqlSession sqlSession = MybatisHelper.getSqlSession();
+ try {
+ CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
+ Example example = Example.builder(Country.class).build();
+ List countries = mapper.selectByExample(example);
+ Assert.assertEquals(183, countries.size());
+ } finally {
+ sqlSession.close();
+ }
+ }
+
+
+ @Test
+ public void testEqualTo() {
+ SqlSession sqlSession = MybatisHelper.getSqlSession();
+ try {
+ CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
+ Example example = Example.builder(Country.class)
+ .where(Sqls.custom().andEqualTo("id", "35"))
+ .build();
+ List countries = mapper.selectByExample(example);
+ Country country = countries.get(0);
+ Assert.assertEquals(Integer.valueOf(35), country.getId());
+ Assert.assertEquals("China", country.getCountryname());
+ Assert.assertEquals("CN", country.getCountrycode());
+
+ } finally {
+ sqlSession.close();
+ }
+ }
+
+ @Test
+ public void testBetween() {
+ SqlSession sqlSession = MybatisHelper.getSqlSession();
+ try {
+ CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
+ Example example = Example.builder(Country.class)
+ .where(Sqls.custom().andBetween("id", 34, 35))
+ .build();
+ List countries = mapper.selectByExample(example);
+ Country country35 = countries.get(0);
+ Assert.assertEquals(Integer.valueOf(35), country35.getId());
+ Assert.assertEquals("China", country35.getCountryname());
+ Assert.assertEquals("CN", country35.getCountrycode());
+
+ Country country34 = countries.get(1);
+ Assert.assertEquals(Integer.valueOf(34), country34.getId());
+ Assert.assertEquals("Chile", country34.getCountryname());
+ Assert.assertEquals("CL", country34.getCountrycode());
+
+ } finally {
+ sqlSession.close();
+ }
+ }
+
+ @Test
+ public void testIn() {
+ SqlSession sqlSession = MybatisHelper.getSqlSession();
+ try {
+ CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
+ Example example = Example.builder(Country.class)
+ .where(Sqls.custom().andIn("id", new ArrayList(Arrays.asList(35, 183))))
+ .build();
+ List countries = mapper.selectByExample(example);
+ Country country35 = countries.get(1);
+ Assert.assertEquals(Integer.valueOf(35), country35.getId());
+ Assert.assertEquals("China", country35.getCountryname());
+ Assert.assertEquals("CN", country35.getCountrycode());
+
+ Country country183 = countries.get(0);
+ Assert.assertEquals(Integer.valueOf(183), country183.getId());
+ Assert.assertEquals("Zambia", country183.getCountryname());
+ Assert.assertEquals("ZM", country183.getCountrycode());
+
+ } finally {
+ sqlSession.close();
+ }
+ }
+
+ @Test
+ public void testCompound() {
+ SqlSession sqlSession = MybatisHelper.getSqlSession();
+ try {
+ CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
+ Example example = Example.builder(Country.class)
+ .where(Sqls.custom()
+ .andEqualTo("countryname", "China")
+ .andEqualTo("id", 35)
+ .orIn("id", new ArrayList(Arrays.asList(35, 183)))
+ .orLike("countryname","Ye%")
+ )
+ .build();
+ List countries = mapper.selectByExample(example);
+ Country country35 = countries.get(2);
+ Assert.assertEquals(Integer.valueOf(35), country35.getId());
+ Assert.assertEquals("China", country35.getCountryname());
+ Assert.assertEquals("CN", country35.getCountrycode());
+
+ Country country183 = countries.get(0);
+ Assert.assertEquals(Integer.valueOf(183), country183.getId());
+ Assert.assertEquals("Zambia", country183.getCountryname());
+ Assert.assertEquals("ZM", country183.getCountrycode());
+
+ Country country179 = countries.get(1);
+ Assert.assertEquals(Integer.valueOf(179), country179.getId());
+ Assert.assertEquals("Yemen", country179.getCountryname());
+ Assert.assertEquals("YE", country179.getCountrycode());
+
+ } finally {
+ sqlSession.close();
+ }
+ }
+
+ @Test
+ public void testWhereAndWhereCompound() {
+ SqlSession sqlSession = MybatisHelper.getSqlSession();
+ try {
+ CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
+ Example example = Example.builder(Country.class)
+ .where(Sqls.custom()
+ .andEqualTo("countryname", "China")
+ .andEqualTo("id", 35)
+ )
+ .andWhere(Sqls.custom()
+ .andEqualTo("id", 183)
+ )
+ .build();
+ List countries = mapper.selectByExample(example);
+ Assert.assertEquals(0, countries.size());
+
+ } finally {
+ sqlSession.close();
+ }
+ }
+
+ @Test
+ public void testWhereOrWhereCompound() {
+ SqlSession sqlSession = MybatisHelper.getSqlSession();
+ try {
+ CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
+ Example example = Example.builder(Country.class)
+ .where(Sqls.custom()
+ .andEqualTo("countryname", "China")
+ .andEqualTo("id", 35)
+ )
+ .orWhere(Sqls.custom()
+ .andEqualTo("id", 183)
+ )
+ .build();
+ List countries = mapper.selectByExample(example);
+ Assert.assertEquals(2, countries.size());
+
+ } finally {
+ sqlSession.close();
+ }
+ }
+}
From 030bc1e9461cdeb2bb4c73637c30fd6f050745ea Mon Sep 17 00:00:00 2001
From: wuyi5
Date: Mon, 20 Nov 2017 10:07:46 +0800
Subject: [PATCH 100/428] =?UTF-8?q?=E6=B7=BB=E5=8A=A0order=20by=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../tk/mybatis/mapper/entity/Example.java | 60 ++++++++++++++++---
.../test/example/TestExampleBuilder.java | 29 ++++++++-
2 files changed, 77 insertions(+), 12 deletions(-)
diff --git a/src/main/java/tk/mybatis/mapper/entity/Example.java b/src/main/java/tk/mybatis/mapper/entity/Example.java
index ab53927d7..08b7dd509 100644
--- a/src/main/java/tk/mybatis/mapper/entity/Example.java
+++ b/src/main/java/tk/mybatis/mapper/entity/Example.java
@@ -114,7 +114,8 @@ private Example(Builder builder) {
this.entityClass = builder.entityClass;
this.propertyMap = builder.propertyMap;
this.oredCriteria = builder.exampleCriterias;
- this.ORDERBY = new OrderBy(this, propertyMap);
+ this.orderByClause = builder.orderByClause.toString();
+ this.forUpdate = builder.forUpdate;
}
public static Builder builder(Class> entityClass) {
@@ -914,10 +915,8 @@ public void setTableName(String tableName) {
this.tableName = tableName;
}
-
-
public static class Builder {
- private String orderByClause;
+ private StringBuilder orderByClause;
private boolean distinct;
@@ -961,15 +960,16 @@ public Builder(Class> entityClass, boolean exists, boolean notNull) {
this.entityClass = entityClass;
this.exists = exists;
this.notNull = notNull;
+ this.orderByClause = new StringBuilder();
this.table = EntityHelper.getEntityTable(entityClass);
this.propertyMap = table.getPropertyMap();
this.sqlsCriteria = new ArrayList(2);
}
- public Builder setOrderByClause(String orderByClause) {
- this.orderByClause = orderByClause;
- return this;
- }
+// public Builder setOrderByClause(String orderByClause) {
+// this.orderByClause = orderByClause;
+// return this;
+// }
public Builder distinct() {
return setDistinct(true);
@@ -1005,7 +1005,7 @@ public Builder notSelect(String... properties) {
return this;
}
- public Builder fromTable(String tableName) {
+ public Builder from(String tableName) {
return setTableName(tableName);
}
@@ -1035,6 +1035,33 @@ public Builder orWhere(Sqls sqls) {
return this;
}
+ public Builder orderBy(String... properties) {
+ return orderByAsc(properties);
+ }
+
+ public Builder orderByAsc(String... properties) {
+ contactOrderByClause(" Asc", properties);
+ return this;
+ }
+
+ public Builder orderByDesc(String... properties) {
+ contactOrderByClause(" Desc", properties);
+ return this;
+ }
+
+ private void contactOrderByClause(String order, String... properties) {
+ StringBuilder columns = new StringBuilder();
+ for (String property : properties) {
+ String column;
+ if ((column = propertyforOderBy(property)) != null) {
+ columns.append(",").append(column);
+ }
+ }
+ columns.append(order);
+ if (columns.length() > 0) {
+ orderByClause.append(columns);
+ }
+ }
public Example build() {
this.exampleCriterias = new ArrayList();
@@ -1051,6 +1078,10 @@ public Example build() {
exampleCriterias.add(exampleCriteria);
}
+ if (this.orderByClause.length() > 0) {
+ this.orderByClause = new StringBuilder(this.orderByClause.substring(1, this.orderByClause.length()));
+ }
+
Example innerExample = new Example(this);
innerExample.selectProperties(this.selectColumns);
innerExample.excludeProperties(this.excludeColumns);
@@ -1099,5 +1130,16 @@ private String property(String property) {
return null;
}
}
+
+ private String propertyforOderBy(String property) {
+ if (StringUtil.isEmpty(property) || StringUtil.isEmpty(property.trim())) {
+ throw new MapperException("接收的property为空!");
+ }
+ property = property.trim();
+ if (!propertyMap.containsKey(property)) {
+ throw new MapperException("当前实体类不包含名为" + property + "的属性!");
+ }
+ return propertyMap.get(property).getColumn();
+ }
}
}
\ No newline at end of file
diff --git a/src/test/java/tk/mybatis/mapper/test/example/TestExampleBuilder.java b/src/test/java/tk/mybatis/mapper/test/example/TestExampleBuilder.java
index a4ab35008..e528d9735 100644
--- a/src/test/java/tk/mybatis/mapper/test/example/TestExampleBuilder.java
+++ b/src/test/java/tk/mybatis/mapper/test/example/TestExampleBuilder.java
@@ -141,11 +141,11 @@ public void testWhereAndWhereCompound() {
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
Example example = Example.builder(Country.class)
.where(Sqls.custom()
- .andEqualTo("countryname", "China")
- .andEqualTo("id", 35)
+ .andEqualTo("countryname", "China")
+ .andEqualTo("id", 35)
)
.andWhere(Sqls.custom()
- .andEqualTo("id", 183)
+ .andEqualTo("id", 183)
)
.build();
List countries = mapper.selectByExample(example);
@@ -177,4 +177,27 @@ public void testWhereOrWhereCompound() {
sqlSession.close();
}
}
+
+ /*
+ * @description: 测试order by
+ * orderBy()默认为Asc(升序),与orderByAsc()一样
+ * */
+ @Test
+ public void testOrderBy() {
+ SqlSession sqlSession = MybatisHelper.getSqlSession();
+ try {
+ CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
+ Example example = Example.builder(Country.class)
+ .where(Sqls.custom().andBetween("id", 50, 55))
+ .orderBy("id").orderByAsc("countryname").orderByDesc("countrycode")
+ .build();
+ List countries = mapper.selectByExample(example);
+ for (Country country :countries) {
+ System.out.println(country.getId() + " " + country.getCountryname() + " " + country.getCountrycode());
+ }
+ Assert.assertEquals(6, countries.size());
+ } finally {
+ sqlSession.close();
+ }
+ }
}
From 4b0699b1e0e8d5e0c5f00339b2d5969cdaec97a5 Mon Sep 17 00:00:00 2001
From: wuyi5
Date: Mon, 20 Nov 2017 10:54:07 +0800
Subject: [PATCH 101/428] =?UTF-8?q?=E6=B7=BB=E5=8A=A0distinct=E5=8D=95?=
=?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../tk/mybatis/mapper/entity/Example.java | 46 ++++++++++++-------
.../test/example/TestExampleBuilder.java | 24 ++++++++++
2 files changed, 54 insertions(+), 16 deletions(-)
diff --git a/src/main/java/tk/mybatis/mapper/entity/Example.java b/src/main/java/tk/mybatis/mapper/entity/Example.java
index 08b7dd509..f2450365b 100644
--- a/src/main/java/tk/mybatis/mapper/entity/Example.java
+++ b/src/main/java/tk/mybatis/mapper/entity/Example.java
@@ -111,8 +111,11 @@ public Example(Class> entityClass, boolean exists, boolean notNull) {
private Example(Builder builder) {
this.exists = builder.exists;
this.notNull = builder.notNull;
+ this.distinct = builder.distinct;
this.entityClass = builder.entityClass;
this.propertyMap = builder.propertyMap;
+ this.selectColumns = builder.selectColumns;
+ this.excludeColumns = builder.excludeColumns;
this.oredCriteria = builder.exampleCriterias;
this.orderByClause = builder.orderByClause.toString();
this.forUpdate = builder.forUpdate;
@@ -927,10 +930,10 @@ public static class Builder {
private boolean forUpdate;
//查询字段
- private String[] selectColumns;
+ private Set selectColumns;
//排除的查询字段
- private String[] excludeColumns;
+ private Set excludeColumns;
private String countColumn;
@@ -966,11 +969,6 @@ public Builder(Class> entityClass, boolean exists, boolean notNull) {
this.sqlsCriteria = new ArrayList(2);
}
-// public Builder setOrderByClause(String orderByClause) {
-// this.orderByClause = orderByClause;
-// return this;
-// }
-
public Builder distinct() {
return setDistinct(true);
}
@@ -990,18 +988,36 @@ public Builder setForUpdate(boolean forUpdate) {
}
public Builder selectDistinct(String... properties) {
- this.selectColumns = properties;
- this.distinct = distinct;
+ select(properties);
+ this.distinct = true;
return this;
}
public Builder select(String... properties) {
- this.selectColumns = properties;
+ if (properties != null && properties.length > 0) {
+ if (this.selectColumns == null) {
+ this.selectColumns = new LinkedHashSet();
+ }
+ for (String property : properties) {
+ if (this.propertyMap.containsKey(property)) {
+ this.selectColumns.add(propertyMap.get(property).getColumn());
+ }
+ }
+ }
return this;
}
public Builder notSelect(String... properties) {
- this.excludeColumns = properties;
+ if (properties != null && properties.length > 0) {
+ if (this.excludeColumns == null) {
+ this.excludeColumns = new LinkedHashSet();
+ }
+ for (String property : properties) {
+ if (propertyMap.containsKey(property)) {
+ this.excludeColumns.add(propertyMap.get(property).getColumn());
+ }
+ }
+ }
return this;
}
@@ -1080,13 +1096,11 @@ public Example build() {
if (this.orderByClause.length() > 0) {
this.orderByClause = new StringBuilder(this.orderByClause.substring(1, this.orderByClause.length()));
+ } else {
+ this.orderByClause.append("id desc");
}
- Example innerExample = new Example(this);
- innerExample.selectProperties(this.selectColumns);
- innerExample.excludeProperties(this.excludeColumns);
-
- return innerExample;
+ return new Example(this);
}
private void transformCriterion(Example.Criteria exampleCriteria, String condition, String property, Object[] values, String andOr) {
diff --git a/src/test/java/tk/mybatis/mapper/test/example/TestExampleBuilder.java b/src/test/java/tk/mybatis/mapper/test/example/TestExampleBuilder.java
index e528d9735..dee54166e 100644
--- a/src/test/java/tk/mybatis/mapper/test/example/TestExampleBuilder.java
+++ b/src/test/java/tk/mybatis/mapper/test/example/TestExampleBuilder.java
@@ -27,11 +27,35 @@ public void testExampleBuilder() {
Example example = Example.builder(Country.class).build();
List countries = mapper.selectByExample(example);
Assert.assertEquals(183, countries.size());
+
+ // 下面的查询会有缓存
+ Example example0 = Example.builder(Country.class)
+ .select().build();
+ List countries0 = mapper.selectByExample(example0);
+ Assert.assertEquals(183, countries0.size());
} finally {
sqlSession.close();
}
}
+ @Test
+ public void testDistinct() {
+ SqlSession sqlSession = MybatisHelper.getSqlSession();
+ try {
+ CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
+ Example example = Example.builder(Country.class)
+ .distinct().build();
+ List countries = mapper.selectByExample(example);
+ Assert.assertEquals(183, countries.size());
+
+ Example example0 = Example.builder(Country.class)
+ .selectDistinct("countryname").build();
+ List countries0 = mapper.selectByExample(example0);
+ Assert.assertEquals(183, countries0.size());
+ } finally {
+ sqlSession.close();
+ }
+ }
@Test
public void testEqualTo() {
From ecd84e5fb0b813b1f0ade861a78070782d7ff000 Mon Sep 17 00:00:00 2001
From: wuyi5
Date: Mon, 20 Nov 2017 11:16:32 +0800
Subject: [PATCH 102/428] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8D=95=E5=85=83?=
=?UTF-8?q?=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../test/example/TestExampleBuilder.java | 48 ++++++++++++++++++-
1 file changed, 46 insertions(+), 2 deletions(-)
diff --git a/src/test/java/tk/mybatis/mapper/test/example/TestExampleBuilder.java b/src/test/java/tk/mybatis/mapper/test/example/TestExampleBuilder.java
index dee54166e..0d30c22e9 100644
--- a/src/test/java/tk/mybatis/mapper/test/example/TestExampleBuilder.java
+++ b/src/test/java/tk/mybatis/mapper/test/example/TestExampleBuilder.java
@@ -57,6 +57,24 @@ public void testDistinct() {
}
}
+ @Test
+ public void testForUpdate() {
+ SqlSession sqlSession = MybatisHelper.getSqlSession();
+ try {
+ CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
+ Example example = Example.builder(Country.class)
+ .select("countryname")
+ .where(Sqls.custom().andGreaterThan("id", 100))
+ .orderByAsc("countrycode")
+ .forUpdate()
+ .build();
+ List countries = mapper.selectByExample(example);
+ Assert.assertEquals(83, countries.size());
+ } finally {
+ sqlSession.close();
+ }
+ }
+
@Test
public void testEqualTo() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
@@ -123,9 +141,11 @@ public void testIn() {
sqlSession.close();
}
}
-
+ /*
+ * @description: 单个where组合查询测试
+ * */
@Test
- public void testCompound() {
+ public void testWhereCompound0() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
@@ -158,6 +178,30 @@ public void testCompound() {
}
}
+ /*
+ * @description: 单个where组合查询测试
+ * */
+ @Test
+ public void testWhereCompound1() {
+ SqlSession sqlSession = MybatisHelper.getSqlSession();
+ try {
+ CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
+ Example example = Example.builder(Country.class)
+ .where(Sqls.custom()
+ .andBetween("id", 35, 50)
+ .orLessThan("id", 40)
+ .orIsNull("countryname")
+ )
+ .build();
+ List countries = mapper.selectByExample(example);
+ Assert.assertEquals(50, countries.size());
+ } finally {
+ sqlSession.close();
+ }
+ }
+ /*
+ * @description: 多个where连接的查询语句
+ * */
@Test
public void testWhereAndWhereCompound() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
From 69eb965835606a26550ba1c780d71c84a8539a7c Mon Sep 17 00:00:00 2001
From: wuyi5
Date: Mon, 20 Nov 2017 12:47:35 +0800
Subject: [PATCH 103/428] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8D=95=E5=85=83?=
=?UTF-8?q?=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../tk/mybatis/mapper/entity/Example.java | 11 +++--
.../test/example/TestExampleBuilder.java | 48 +++++++++++++++++--
2 files changed, 53 insertions(+), 6 deletions(-)
diff --git a/src/main/java/tk/mybatis/mapper/entity/Example.java b/src/main/java/tk/mybatis/mapper/entity/Example.java
index f2450365b..bc4db7a47 100644
--- a/src/main/java/tk/mybatis/mapper/entity/Example.java
+++ b/src/main/java/tk/mybatis/mapper/entity/Example.java
@@ -117,8 +117,11 @@ private Example(Builder builder) {
this.selectColumns = builder.selectColumns;
this.excludeColumns = builder.excludeColumns;
this.oredCriteria = builder.exampleCriterias;
- this.orderByClause = builder.orderByClause.toString();
this.forUpdate = builder.forUpdate;
+
+ if (!StringUtil.isEmpty(builder.orderByClause.toString())) {
+ this.orderByClause = builder.orderByClause.toString();
+ }
}
public static Builder builder(Class> entityClass) {
@@ -1001,6 +1004,8 @@ public Builder select(String... properties) {
for (String property : properties) {
if (this.propertyMap.containsKey(property)) {
this.selectColumns.add(propertyMap.get(property).getColumn());
+ } else {
+ throw new MapperException("当前实体类不包含名为" + property + "的属性!");
}
}
}
@@ -1015,6 +1020,8 @@ public Builder notSelect(String... properties) {
for (String property : properties) {
if (propertyMap.containsKey(property)) {
this.excludeColumns.add(propertyMap.get(property).getColumn());
+ } else {
+ throw new MapperException("当前实体类不包含名为" + property + "的属性!");
}
}
}
@@ -1096,8 +1103,6 @@ public Example build() {
if (this.orderByClause.length() > 0) {
this.orderByClause = new StringBuilder(this.orderByClause.substring(1, this.orderByClause.length()));
- } else {
- this.orderByClause.append("id desc");
}
return new Example(this);
diff --git a/src/test/java/tk/mybatis/mapper/test/example/TestExampleBuilder.java b/src/test/java/tk/mybatis/mapper/test/example/TestExampleBuilder.java
index 0d30c22e9..2096e1fe9 100644
--- a/src/test/java/tk/mybatis/mapper/test/example/TestExampleBuilder.java
+++ b/src/test/java/tk/mybatis/mapper/test/example/TestExampleBuilder.java
@@ -44,12 +44,14 @@ public void testDistinct() {
try {
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
Example example = Example.builder(Country.class)
- .distinct().build();
+ .distinct()
+ .build();
List countries = mapper.selectByExample(example);
Assert.assertEquals(183, countries.size());
+ // distinct和order by冲突问题
Example example0 = Example.builder(Country.class)
- .selectDistinct("countryname").build();
+ .selectDistinct("id", "countryname").build();
List countries0 = mapper.selectByExample(example0);
Assert.assertEquals(183, countries0.size());
} finally {
@@ -200,7 +202,7 @@ public void testWhereCompound1() {
}
}
/*
- * @description: 多个where连接的查询语句
+ * @description: 多个where连接的查询语句测试
* */
@Test
public void testWhereAndWhereCompound() {
@@ -224,6 +226,9 @@ public void testWhereAndWhereCompound() {
}
}
+ /*
+ * @description: 多个where连接的查询语句测试
+ * */
@Test
public void testWhereOrWhereCompound() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
@@ -246,6 +251,43 @@ public void testWhereOrWhereCompound() {
}
}
+ /*
+ * @description: 多个where连接的查询语句测试
+ * */
+ @Test
+ public void testMultiWhereCompound() {
+ SqlSession sqlSession = MybatisHelper.getSqlSession();
+ try {
+ CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
+ Example example = Example.builder(Country.class)
+ .selectDistinct()
+ .where(Sqls.custom()
+ .andEqualTo("countryname", "China")
+ .andEqualTo("id", 35)
+ )
+ .orWhere(Sqls.custom()
+ .andBetween("countryname", 'C', 'H')
+ .andNotLike("countryname", "Co%")
+ )
+ .andWhere(Sqls.custom()
+ .andLessThan("id", "100")
+ .orGreaterThan("id", "55")
+ )
+ .orWhere(Sqls.custom()
+ .andEqualTo("countryname", "Cook Is.")
+ )
+ .orderByAsc("id", "countryname")
+ .orderByDesc("countrycode")
+ .forUpdate()
+ .build();
+ List countries = mapper.selectByExample(example);
+ Assert.assertEquals(35, countries.size());
+
+ } finally {
+ sqlSession.close();
+ }
+ }
+
/*
* @description: 测试order by
* orderBy()默认为Asc(升序),与orderByAsc()一样
From 3750d5e20152ff1bdd510fe846c4c248dfef6508 Mon Sep 17 00:00:00 2001
From: wuyi5
Date: Mon, 20 Nov 2017 12:58:48 +0800
Subject: [PATCH 104/428] =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E6=8A=8Aexample?=
=?UTF-8?q?=E7=9A=84=E6=9E=84=E9=80=A0=E6=94=BE=E5=88=B0selectByExample()?=
=?UTF-8?q?=E5=87=BD=E6=95=B0=E9=87=8C=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../tk/mybatis/mapper/test/example/TestExampleBuilder.java | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/test/java/tk/mybatis/mapper/test/example/TestExampleBuilder.java b/src/test/java/tk/mybatis/mapper/test/example/TestExampleBuilder.java
index 2096e1fe9..e868e4310 100644
--- a/src/test/java/tk/mybatis/mapper/test/example/TestExampleBuilder.java
+++ b/src/test/java/tk/mybatis/mapper/test/example/TestExampleBuilder.java
@@ -145,21 +145,22 @@ public void testIn() {
}
/*
* @description: 单个where组合查询测试
+ * 直接把example的构造放到selectByExample()函数里
* */
@Test
public void testWhereCompound0() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
- Example example = Example.builder(Country.class)
+ List countries = mapper.selectByExample(
+ Example.builder(Country.class)
.where(Sqls.custom()
.andEqualTo("countryname", "China")
.andEqualTo("id", 35)
.orIn("id", new ArrayList(Arrays.asList(35, 183)))
.orLike("countryname","Ye%")
)
- .build();
- List countries = mapper.selectByExample(example);
+ .build());
Country country35 = countries.get(2);
Assert.assertEquals(Integer.valueOf(35), country35.getId());
Assert.assertEquals("China", country35.getCountryname());
From 5b5907d9167db14fb9022ef9f6cba775f7f33d4f Mon Sep 17 00:00:00 2001
From: wuyi5
Date: Mon, 20 Nov 2017 13:12:50 +0800
Subject: [PATCH 105/428] =?UTF-8?q?=E5=9C=A8builder=E6=9E=84=E5=BB=BA?=
=?UTF-8?q?=E4=B8=AD=EF=BC=8C=E6=B7=BB=E5=8A=A0tableName=E7=9A=84=E5=88=9D?=
=?UTF-8?q?=E5=A7=8B=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/tk/mybatis/mapper/entity/Example.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/main/java/tk/mybatis/mapper/entity/Example.java b/src/main/java/tk/mybatis/mapper/entity/Example.java
index bc4db7a47..4600cfb0a 100644
--- a/src/main/java/tk/mybatis/mapper/entity/Example.java
+++ b/src/main/java/tk/mybatis/mapper/entity/Example.java
@@ -118,6 +118,7 @@ private Example(Builder builder) {
this.excludeColumns = builder.excludeColumns;
this.oredCriteria = builder.exampleCriterias;
this.forUpdate = builder.forUpdate;
+ this.tableName = builder.tableName;
if (!StringUtil.isEmpty(builder.orderByClause.toString())) {
this.orderByClause = builder.orderByClause.toString();
From 0ec57fbccc01d52cbbface8a5aedc6ae14085cc9 Mon Sep 17 00:00:00 2001
From: isea533
Date: Sun, 17 Dec 2017 21:22:11 +0800
Subject: [PATCH 106/428] =?UTF-8?q?=E5=8F=91=E5=B8=83=203.4.6=20=E7=89=88?=
=?UTF-8?q?=E6=9C=AC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 2 +-
wiki/Changelog.md | 32 +++++++++++++++++++++++++++++++-
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 1cb4dab94..d31cc33b5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
tk.mybatis
mapper
- 3.4.6-SNAPSHOT
+ 3.4.6
jar
mapper
diff --git a/wiki/Changelog.md b/wiki/Changelog.md
index 1c3222b14..020899b4f 100644
--- a/wiki/Changelog.md
+++ b/wiki/Changelog.md
@@ -1,9 +1,39 @@
# 更新日志
-## 3.4.6-SNAPSHOT
+## 3.4.6
+- `Example` 新增 builder 模式(by [Ngone51](https://github.com/abel533/Mapper/commits?author=Ngone51))。
- 设置下划线风格替换为驼峰风格的Pattern为StringUtil的静态变量(by [Ngone51](https://github.com/abel533/Mapper/commits?author=Ngone51))。
+一个简单的 builder 用法示例:
+```java
+/*
+ * @description: 多个where连接的查询语句测试
+ *
+ */
+@Test
+public void testWhereAndWhereCompound() {
+ SqlSession sqlSession = MybatisHelper.getSqlSession();
+ try {
+ CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
+ Example example = Example.builder(Country.class)
+ .where(Sqls.custom()
+ .andEqualTo("countryname", "China")
+ .andEqualTo("id", 35)
+ )
+ .andWhere(Sqls.custom()
+ .andEqualTo("id", 183)
+ )
+ .build();
+ List countries = mapper.selectByExample(example);
+ Assert.assertEquals(0, countries.size());
+
+ } finally {
+ sqlSession.close();
+ }
+}
+```
+更多用法可以通过测试 [`TestExampleBuilder`](https://github.com/abel533/Mapper/blob/master/src/test/java/tk/mybatis/mapper/test/example/TestExampleBuilder.java) 了解。
## 3.4.5 - 2017-11-11
From 34982116880d8b8d3f3e5684411d414e00fe529b Mon Sep 17 00:00:00 2001
From: isea533
Date: Sat, 30 Dec 2017 11:34:13 +0800
Subject: [PATCH 107/428] =?UTF-8?q?=E5=85=BC=E5=AE=B9=20mbg=201.3.6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 2 +-
.../generator/MapperCommentGenerator.java | 41 +++++++++++++++++++
.../resources/generator/generatorConfig.xml | 2 +-
3 files changed, 43 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index d31cc33b5..8696db30a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -116,7 +116,7 @@
org.mybatis.generator
mybatis-generator-core
- 1.3.5
+ 1.3.6
compile
true
diff --git a/src/main/java/tk/mybatis/mapper/generator/MapperCommentGenerator.java b/src/main/java/tk/mybatis/mapper/generator/MapperCommentGenerator.java
index fce43fa32..638d3bf13 100644
--- a/src/main/java/tk/mybatis/mapper/generator/MapperCommentGenerator.java
+++ b/src/main/java/tk/mybatis/mapper/generator/MapperCommentGenerator.java
@@ -35,6 +35,7 @@
import java.text.MessageFormat;
import java.util.Properties;
+import java.util.Set;
public class MapperCommentGenerator implements CommentGenerator {
//开始的分隔符,例如mysql为`,sqlserver为[
@@ -273,4 +274,44 @@ public void addSetterComment(Method method, IntrospectedTable introspectedTable,
@Override
public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable, boolean markAsDoNotDelete) {
}
+
+ /**
+ * @since mbg 1.3.6
+ */
+ @Override
+ public void addGeneralMethodAnnotation(Method method, IntrospectedTable introspectedTable, Set set) {
+
+ }
+
+ /**
+ * @since mbg 1.3.6
+ */
+ @Override
+ public void addGeneralMethodAnnotation(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn, Set set) {
+
+ }
+
+ /**
+ * @since mbg 1.3.6
+ */
+ @Override
+ public void addFieldAnnotation(Field field, IntrospectedTable introspectedTable, Set set) {
+
+ }
+
+ /**
+ * @since mbg 1.3.6
+ */
+ @Override
+ public void addFieldAnnotation(Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn, Set set) {
+
+ }
+
+ /**
+ * @since mbg 1.3.6
+ */
+ @Override
+ public void addClassAnnotation(InnerClass innerClass, IntrospectedTable introspectedTable, Set set) {
+
+ }
}
diff --git a/src/test/resources/generator/generatorConfig.xml b/src/test/resources/generator/generatorConfig.xml
index b78086815..1fb1aa757 100644
--- a/src/test/resources/generator/generatorConfig.xml
+++ b/src/test/resources/generator/generatorConfig.xml
@@ -79,7 +79,7 @@