+ * 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
+ *
- * 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
- *
- * 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">
+
-
-
-
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
+
-
-
-
From 184a8cace2182f8c47003494af103daa37dbfaea Mon Sep 17 00:00:00 2001
From: isea533
Date: Mon, 1 Jan 2018 21:21:05 +0800
Subject: [PATCH 087/407] =?UTF-8?q?EntityColumn=20=E8=AE=B0=E5=BD=95=20Ent?=
=?UTF-8?q?ityField=20=E4=BF=A1=E6=81=AF=EF=BC=8C=E6=96=B9=E4=BE=BF?=
=?UTF-8?q?=E5=90=8E=E7=BB=AD=E6=89=A9=E5=B1=95=E4=BD=BF=E7=94=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../tk/mybatis/mapper/entity/EntityColumn.java | 14 ++++++++++++++
.../mybatis/mapper/mapperhelper/EntityHelper.java | 2 ++
2 files changed, 16 insertions(+)
diff --git a/src/main/java/tk/mybatis/mapper/entity/EntityColumn.java b/src/main/java/tk/mybatis/mapper/entity/EntityColumn.java
index 72e815143..c747a2bc1 100644
--- a/src/main/java/tk/mybatis/mapper/entity/EntityColumn.java
+++ b/src/main/java/tk/mybatis/mapper/entity/EntityColumn.java
@@ -51,6 +51,12 @@ public class EntityColumn {
private boolean insertable = true;
//可更新
private boolean updatable = true;
+ /**
+ * 对应的字段信息
+ *
+ * @since 3.5.0
+ */
+ private EntityField entityField;
public EntityColumn() {
}
@@ -201,6 +207,14 @@ public String getColumnHolder() {
return getColumnHolder(null);
}
+ public EntityField getEntityField() {
+ return entityField;
+ }
+
+ public void setEntityField(EntityField entityField) {
+ this.entityField = entityField;
+ }
+
public String getGenerator() {
return generator;
}
diff --git a/src/main/java/tk/mybatis/mapper/mapperhelper/EntityHelper.java b/src/main/java/tk/mybatis/mapper/mapperhelper/EntityHelper.java
index fa93e47d8..fb7375f1b 100644
--- a/src/main/java/tk/mybatis/mapper/mapperhelper/EntityHelper.java
+++ b/src/main/java/tk/mybatis/mapper/mapperhelper/EntityHelper.java
@@ -251,6 +251,8 @@ private static void processField(EntityTable entityTable, Style style, EntityFie
}
//Id
EntityColumn entityColumn = new EntityColumn(entityTable);
+ //记录 field 信息,方便后续扩展使用
+ entityColumn.setEntityField(field);
if (field.isAnnotationPresent(Id.class)) {
entityColumn.setId(true);
}
From 914ed4b18eed4362439722d6c7f12d511cbb99aa Mon Sep 17 00:00:00 2001
From: isea533
Date: Mon, 1 Jan 2018 21:29:17 +0800
Subject: [PATCH 088/407] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20SelectOneByExample?=
=?UTF-8?q?Mapper=20=E6=96=B9=E6=B3=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../mybatis/mapper/common/ExampleMapper.java | 1 +
.../example/SelectOneByExampleMapper.java | 47 +++++++++++++
.../mapper/provider/ExampleProvider.java | 20 ++++--
.../test/example/TestSelectOneByExample.java | 70 +++++++++++++++++++
4 files changed, 133 insertions(+), 5 deletions(-)
create mode 100644 src/main/java/tk/mybatis/mapper/common/example/SelectOneByExampleMapper.java
create mode 100644 src/test/java/tk/mybatis/mapper/test/example/TestSelectOneByExample.java
diff --git a/src/main/java/tk/mybatis/mapper/common/ExampleMapper.java b/src/main/java/tk/mybatis/mapper/common/ExampleMapper.java
index 8002103a2..b724809c2 100644
--- a/src/main/java/tk/mybatis/mapper/common/ExampleMapper.java
+++ b/src/main/java/tk/mybatis/mapper/common/ExampleMapper.java
@@ -34,6 +34,7 @@
*/
public interface ExampleMapper extends
SelectByExampleMapper,
+ SelectOneByExampleMapper,
SelectCountByExampleMapper,
DeleteByExampleMapper,
UpdateByExampleMapper,
diff --git a/src/main/java/tk/mybatis/mapper/common/example/SelectOneByExampleMapper.java b/src/main/java/tk/mybatis/mapper/common/example/SelectOneByExampleMapper.java
new file mode 100644
index 000000000..7c0350143
--- /dev/null
+++ b/src/main/java/tk/mybatis/mapper/common/example/SelectOneByExampleMapper.java
@@ -0,0 +1,47 @@
+/*
+ * 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.common.example;
+
+import org.apache.ibatis.annotations.SelectProvider;
+import tk.mybatis.mapper.provider.ExampleProvider;
+
+/**
+ * 通用Mapper接口,Example查询
+ *
+ * @param 不能为空
+ * @author liuzh
+ */
+public interface SelectOneByExampleMapper {
+
+ /**
+ * 根据Example条件进行查询
+ *
+ * @param example
+ * @return
+ */
+ @SelectProvider(type = ExampleProvider.class, method = "dynamicSQL")
+ T selectOneByExample(Object example);
+
+}
\ No newline at end of file
diff --git a/src/main/java/tk/mybatis/mapper/provider/ExampleProvider.java b/src/main/java/tk/mybatis/mapper/provider/ExampleProvider.java
index 579f87932..582e24ea0 100644
--- a/src/main/java/tk/mybatis/mapper/provider/ExampleProvider.java
+++ b/src/main/java/tk/mybatis/mapper/provider/ExampleProvider.java
@@ -49,7 +49,7 @@ public ExampleProvider(Class> mapperClass, MapperHelper mapperHelper) {
public String selectCountByExample(MappedStatement ms) {
Class> entityClass = getEntityClass(ms);
StringBuilder sql = new StringBuilder();
- if(isCheckExampleEntityClass()){
+ if (isCheckExampleEntityClass()) {
sql.append(SqlHelper.exampleCheck(entityClass));
}
sql.append(SqlHelper.selectCount(entityClass));
@@ -68,7 +68,7 @@ public String selectCountByExample(MappedStatement ms) {
public String deleteByExample(MappedStatement ms) {
Class> entityClass = getEntityClass(ms);
StringBuilder sql = new StringBuilder();
- if(isCheckExampleEntityClass()){
+ if (isCheckExampleEntityClass()) {
sql.append(SqlHelper.exampleCheck(entityClass));
}
sql.append(SqlHelper.deleteFromTable(entityClass, tableName(entityClass)));
@@ -88,7 +88,7 @@ public String selectByExample(MappedStatement ms) {
//将返回值修改为实体类型
setResultType(ms, entityClass);
StringBuilder sql = new StringBuilder("SELECT ");
- if(isCheckExampleEntityClass()){
+ if (isCheckExampleEntityClass()) {
sql.append(SqlHelper.exampleCheck(entityClass));
}
sql.append("distinct");
@@ -120,7 +120,7 @@ public String selectByExampleAndRowBounds(MappedStatement ms) {
public String updateByExampleSelective(MappedStatement ms) {
Class> entityClass = getEntityClass(ms);
StringBuilder sql = new StringBuilder();
- if(isCheckExampleEntityClass()){
+ if (isCheckExampleEntityClass()) {
sql.append(SqlHelper.exampleCheck(entityClass));
}
sql.append(SqlHelper.updateTable(entityClass, tableName(entityClass), "example"));
@@ -138,7 +138,7 @@ public String updateByExampleSelective(MappedStatement ms) {
public String updateByExample(MappedStatement ms) {
Class> entityClass = getEntityClass(ms);
StringBuilder sql = new StringBuilder();
- if(isCheckExampleEntityClass()){
+ if (isCheckExampleEntityClass()) {
sql.append(SqlHelper.exampleCheck(entityClass));
}
sql.append(SqlHelper.updateTable(entityClass, tableName(entityClass), "example"));
@@ -146,4 +146,14 @@ public String updateByExample(MappedStatement ms) {
sql.append(SqlHelper.updateByExampleWhereClause());
return sql.toString();
}
+
+ /**
+ * 根据Example查询一个结果
+ *
+ * @param ms
+ * @return
+ */
+ public String selectOneByExample(MappedStatement ms) {
+ return selectByExample(ms);
+ }
}
diff --git a/src/test/java/tk/mybatis/mapper/test/example/TestSelectOneByExample.java b/src/test/java/tk/mybatis/mapper/test/example/TestSelectOneByExample.java
new file mode 100644
index 000000000..7d98f2064
--- /dev/null
+++ b/src/test/java/tk/mybatis/mapper/test/example/TestSelectOneByExample.java
@@ -0,0 +1,70 @@
+/*
+ * 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.example;
+
+import org.apache.ibatis.exceptions.TooManyResultsException;
+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;
+
+/**
+ * @author liuzh
+ */
+public class TestSelectOneByExample {
+
+ @Test(expected = TooManyResultsException.class)
+ public void testSelectOneByExampleException() {
+ SqlSession sqlSession = MybatisHelper.getSqlSession();
+ try {
+ CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
+ Example example = new Example(Country.class);
+ example.createCriteria().andGreaterThan("id", 100).andLessThan("id", 151);
+ example.or().andLessThan("id", 41);
+ mapper.selectOneByExample(example);
+ } finally {
+ sqlSession.close();
+ }
+ }
+
+ @Test
+ public void testSelectByExample() {
+ SqlSession sqlSession = MybatisHelper.getSqlSession();
+ try {
+ CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
+ Example example = new Example(Country.class);
+ example.createCriteria().andGreaterThan("id", 100).andLessThan("id", 102);
+ Country country = mapper.selectOneByExample(example);
+ Assert.assertNotNull(country);
+ Assert.assertEquals(new Integer(101), country.getId());
+ } finally {
+ sqlSession.close();
+ }
+ }
+
+}
From 08d0f0445ab0db9c00949048f358517d21752ac2 Mon Sep 17 00:00:00 2001
From: isea533
Date: Tue, 2 Jan 2018 21:25:30 +0800
Subject: [PATCH 089/407] =?UTF-8?q?=E9=92=88=E5=AF=B9=20update=20=E4=B8=A4?=
=?UTF-8?q?=E4=B8=AA=E5=9F=BA=E6=9C=AC=E6=96=B9=E6=B3=95=E5=A2=9E=E5=8A=A0?=
=?UTF-8?q?=E4=B9=90=E8=A7=82=E9=94=81=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../tk/mybatis/mapper/annotation/Version.java | 50 +++
.../mapper/mapperhelper/SqlHelper.java | 43 +-
.../provider/base/BaseUpdateProvider.java | 4 +-
.../mapper/version/DefaultNextVersion.java | 47 +++
.../mybatis/mapper/version/NextVersion.java | 41 ++
.../mapper/version/VersionException.java | 48 +++
.../mybatis/mapper/version/VersionUtil.java | 50 +++
.../mapper/mapper/CountryVersionMapper.java | 34 ++
.../mybatis/mapper/model/CountryVersion.java | 49 +++
.../test/country/TestUpdateByPrimaryKey.java | 39 +-
src/test/resources/CreateDB.sql | 371 +++++++++---------
src/test/resources/mybatis-java.xml | 1 +
12 files changed, 588 insertions(+), 189 deletions(-)
create mode 100644 src/main/java/tk/mybatis/mapper/annotation/Version.java
create mode 100644 src/main/java/tk/mybatis/mapper/version/DefaultNextVersion.java
create mode 100644 src/main/java/tk/mybatis/mapper/version/NextVersion.java
create mode 100644 src/main/java/tk/mybatis/mapper/version/VersionException.java
create mode 100644 src/main/java/tk/mybatis/mapper/version/VersionUtil.java
create mode 100644 src/test/java/tk/mybatis/mapper/mapper/CountryVersionMapper.java
create mode 100644 src/test/java/tk/mybatis/mapper/model/CountryVersion.java
diff --git a/src/main/java/tk/mybatis/mapper/annotation/Version.java b/src/main/java/tk/mybatis/mapper/annotation/Version.java
new file mode 100644
index 000000000..17bae8fb0
--- /dev/null
+++ b/src/main/java/tk/mybatis/mapper/annotation/Version.java
@@ -0,0 +1,50 @@
+/*
+ * 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.annotation;
+
+import tk.mybatis.mapper.version.DefaultNextVersion;
+import tk.mybatis.mapper.version.NextVersion;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @author liuzh
+ * @since 3.5.0
+ */
+@Target({ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Version {
+
+ /**
+ * 下一个版本号的算法,默认算法支持 Integer 和 Long,在原基础上 +1
+ *
+ * @return
+ */
+ Class extends NextVersion> nextVersion() default DefaultNextVersion.class;
+
+}
diff --git a/src/main/java/tk/mybatis/mapper/mapperhelper/SqlHelper.java b/src/main/java/tk/mybatis/mapper/mapperhelper/SqlHelper.java
index d20ed4485..e7ccaef71 100644
--- a/src/main/java/tk/mybatis/mapper/mapperhelper/SqlHelper.java
+++ b/src/main/java/tk/mybatis/mapper/mapperhelper/SqlHelper.java
@@ -24,9 +24,11 @@
package tk.mybatis.mapper.mapperhelper;
+import tk.mybatis.mapper.annotation.Version;
import tk.mybatis.mapper.entity.EntityColumn;
import tk.mybatis.mapper.entity.IDynamicTableName;
import tk.mybatis.mapper.util.StringUtil;
+import tk.mybatis.mapper.version.VersionException;
import java.util.Set;
@@ -448,10 +450,26 @@ public static String updateSetColumns(Class> entityClass, String entityName, b
sql.append("");
//获取全部列
Set columnList = EntityHelper.getColumns(entityClass);
+ //对乐观锁的支持
+ EntityColumn versionColumn = null;
//当某个列有主键策略时,不需要考虑他的属性是否为空,因为如果为空,一定会根据主键策略给他生成一个值
for (EntityColumn column : columnList) {
+ if (column.getEntityField().isAnnotationPresent(Version.class)) {
+ if (versionColumn != null) {
+ throw new VersionException(entityClass.getCanonicalName() + " 中包含多个带有 @Version 注解的字段,一个类中只能存在一个带有 @Version 注解的字段!");
+ }
+ versionColumn = column;
+ }
if (!column.isId() && column.isUpdatable()) {
- if (notNull) {
+ if (column == versionColumn) {
+ Version version = versionColumn.getEntityField().getAnnotation(Version.class);
+ String versionClass = version.nextVersion().getCanonicalName();
+ //version = ${@tk.mybatis.mapper.version@nextVersionClass("versionClass", version)}
+ sql.append(column.getColumn())
+ .append(" = ${@tk.mybatis.mapper.version.VersionUtil@nextVersion(\"")
+ .append(versionClass).append("\", ")
+ .append(column.getProperty()).append(")},");
+ } else if (notNull) {
sql.append(SqlHelper.getIfNotNull(entityName, column, column.getColumnEqualsHolder(entityName) + ",", notEmpty));
} else {
sql.append(column.getColumnEqualsHolder(entityName) + ",");
@@ -469,6 +487,16 @@ public static String updateSetColumns(Class> entityClass, String entityName, b
* @return
*/
public static String wherePKColumns(Class> entityClass) {
+ return wherePKColumns(entityClass, false);
+ }
+
+ /**
+ * where主键条件
+ *
+ * @param entityClass
+ * @return
+ */
+ public static String wherePKColumns(Class> entityClass, boolean useVersion) {
StringBuilder sql = new StringBuilder();
sql.append("");
//获取全部列
@@ -477,6 +505,19 @@ public static String wherePKColumns(Class> entityClass) {
for (EntityColumn column : columnList) {
sql.append(" AND " + column.getColumnEqualsHolder());
}
+ if (useVersion) {
+ columnList = EntityHelper.getColumns(entityClass);
+ boolean hasVersion = false;
+ for (EntityColumn column : columnList) {
+ if (column.getEntityField().isAnnotationPresent(Version.class)) {
+ if (hasVersion) {
+ throw new VersionException(entityClass.getCanonicalName() + " 中包含多个带有 @Version 注解的字段,一个类中只能存在一个带有 @Version 注解的字段!");
+ }
+ hasVersion = true;
+ sql.append(" AND " + column.getColumnEqualsHolder());
+ }
+ }
+ }
sql.append("");
return sql.toString();
}
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 4a47bc195..9f2e8335d 100644
--- a/src/main/java/tk/mybatis/mapper/provider/base/BaseUpdateProvider.java
+++ b/src/main/java/tk/mybatis/mapper/provider/base/BaseUpdateProvider.java
@@ -50,7 +50,7 @@ public String updateByPrimaryKey(MappedStatement ms) {
StringBuilder sql = new StringBuilder();
sql.append(SqlHelper.updateTable(entityClass, tableName(entityClass)));
sql.append(SqlHelper.updateSetColumns(entityClass, null, false, false));
- sql.append(SqlHelper.wherePKColumns(entityClass));
+ sql.append(SqlHelper.wherePKColumns(entityClass, true));
return sql.toString();
}
@@ -65,7 +65,7 @@ public String updateByPrimaryKeySelective(MappedStatement ms) {
StringBuilder sql = new StringBuilder();
sql.append(SqlHelper.updateTable(entityClass, tableName(entityClass)));
sql.append(SqlHelper.updateSetColumns(entityClass, null, true, isNotEmpty()));
- sql.append(SqlHelper.wherePKColumns(entityClass));
+ sql.append(SqlHelper.wherePKColumns(entityClass, true));
return sql.toString();
}
}
diff --git a/src/main/java/tk/mybatis/mapper/version/DefaultNextVersion.java b/src/main/java/tk/mybatis/mapper/version/DefaultNextVersion.java
new file mode 100644
index 000000000..4f8f41373
--- /dev/null
+++ b/src/main/java/tk/mybatis/mapper/version/DefaultNextVersion.java
@@ -0,0 +1,47 @@
+/*
+ * 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.version;
+
+/**
+ * @author liuzh
+ * @since 3.5.0
+ */
+public class DefaultNextVersion implements NextVersion {
+
+ @Override
+ public Object nextVersion(Object current) throws VersionException {
+ if (current == null) {
+ throw new VersionException("当前版本号为空!");
+ }
+ if (current instanceof Integer) {
+ return (Integer) current + 1;
+ } else if (current instanceof Long) {
+ return (Long) current + 1L;
+ } else {
+ throw new VersionException("默认的 NextVersion 只支持 Integer 和 Long 类型的版本号,如果有需要请自行扩展!");
+ }
+ }
+
+}
diff --git a/src/main/java/tk/mybatis/mapper/version/NextVersion.java b/src/main/java/tk/mybatis/mapper/version/NextVersion.java
new file mode 100644
index 000000000..a82ebcd60
--- /dev/null
+++ b/src/main/java/tk/mybatis/mapper/version/NextVersion.java
@@ -0,0 +1,41 @@
+/*
+ * 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.version;
+
+/**
+ * @author liuzh
+ * @since 3.5.0
+ */
+public interface NextVersion {
+
+ /**
+ * 返回下一个版本
+ *
+ * @param current
+ * @return
+ */
+ T nextVersion(T current) throws VersionException;
+
+}
diff --git a/src/main/java/tk/mybatis/mapper/version/VersionException.java b/src/main/java/tk/mybatis/mapper/version/VersionException.java
new file mode 100644
index 000000000..d87a0b567
--- /dev/null
+++ b/src/main/java/tk/mybatis/mapper/version/VersionException.java
@@ -0,0 +1,48 @@
+/*
+ * 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.version;
+
+/**
+ * @author liuzh
+ * @since 3.5.0
+ */
+public class VersionException extends RuntimeException {
+ public VersionException() {
+ super();
+ }
+
+ public VersionException(String message) {
+ super(message);
+ }
+
+ public VersionException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public VersionException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/src/main/java/tk/mybatis/mapper/version/VersionUtil.java b/src/main/java/tk/mybatis/mapper/version/VersionUtil.java
new file mode 100644
index 000000000..ec2781eb5
--- /dev/null
+++ b/src/main/java/tk/mybatis/mapper/version/VersionUtil.java
@@ -0,0 +1,50 @@
+/*
+ * 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.version;
+
+/**
+ * @author liuzh
+ * @since 3.5.0
+ */
+public class VersionUtil {
+
+ /**
+ * 获取下一个版本
+ *
+ * @param nextVersionClass
+ * @param current
+ * @return
+ * @throws VersionException
+ */
+ public static Object nextVersion(String nextVersionClass, Object current) throws VersionException {
+ try {
+ NextVersion nextVersion = (NextVersion) Class.forName(nextVersionClass).newInstance();
+ return nextVersion.nextVersion(current);
+ } catch (Exception e) {
+ throw new VersionException("获取下一个版本号失败!", e);
+ }
+ }
+
+}
diff --git a/src/test/java/tk/mybatis/mapper/mapper/CountryVersionMapper.java b/src/test/java/tk/mybatis/mapper/mapper/CountryVersionMapper.java
new file mode 100644
index 000000000..9ca95967f
--- /dev/null
+++ b/src/test/java/tk/mybatis/mapper/mapper/CountryVersionMapper.java
@@ -0,0 +1,34 @@
+/*
+ * 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.mapper;
+
+import tk.mybatis.mapper.common.Mapper;
+import tk.mybatis.mapper.model.CountryVersion;
+
+/**
+ * Created by liuzh on 2014/11/19.
+ */
+public interface CountryVersionMapper extends Mapper {
+}
diff --git a/src/test/java/tk/mybatis/mapper/model/CountryVersion.java b/src/test/java/tk/mybatis/mapper/model/CountryVersion.java
new file mode 100644
index 000000000..bd32873c6
--- /dev/null
+++ b/src/test/java/tk/mybatis/mapper/model/CountryVersion.java
@@ -0,0 +1,49 @@
+/*
+ * 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 tk.mybatis.mapper.annotation.Version;
+
+import javax.persistence.Table;
+
+/**
+ * Description: Country
+ * Author: liuzh
+ * Update: liuzh(2014-06-06 13:38)
+ */
+@Table(name = "country")
+public class CountryVersion extends Country {
+ @Version
+ private Integer version;
+
+ public Integer getVersion() {
+ return version;
+ }
+
+ public void setVersion(Integer version) {
+ this.version = version;
+ }
+
+}
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 ee9b6ba28..a73fef2f9 100644
--- a/src/test/java/tk/mybatis/mapper/test/country/TestUpdateByPrimaryKey.java
+++ b/src/test/java/tk/mybatis/mapper/test/country/TestUpdateByPrimaryKey.java
@@ -28,8 +28,10 @@
import org.junit.Assert;
import org.junit.Test;
import tk.mybatis.mapper.mapper.CountryMapper;
+import tk.mybatis.mapper.mapper.CountryVersionMapper;
import tk.mybatis.mapper.mapper.MybatisHelper;
import tk.mybatis.mapper.model.Country;
+import tk.mybatis.mapper.model.CountryVersion;
/**
* 通过PK更新实体类全部属性
@@ -111,6 +113,42 @@ public void testDynamicUpdateByPrimaryKeyNotFoundKeyProperties() {
}
}
+ /**
+ * 根据查询条件进行查询
+ */
+ @Test
+ public void testUpdateByPrimaryKeyAndVersion() {
+ SqlSession sqlSession = MybatisHelper.getSqlSession();
+ try {
+ CountryVersionMapper mapper = sqlSession.getMapper(CountryVersionMapper.class);
+ CountryVersion country = mapper.selectByPrimaryKey(174);
+ Assert.assertNotNull(country);
+ Assert.assertEquals(new Integer(1), country.getVersion());
+ country.setCountryname("美国2");
+ Assert.assertEquals(1, mapper.updateByPrimaryKey(country));
+
+ country = mapper.selectByPrimaryKey(174);
+ Assert.assertNotNull(country);
+ Assert.assertEquals(new Integer(2), country.getVersion());
+
+ country.setCountryname("美国3");
+ Assert.assertEquals(1, mapper.updateByPrimaryKey(country));
+
+ country = mapper.selectByPrimaryKey(174);
+ Assert.assertNotNull(country);
+ Assert.assertEquals(new Integer(3), country.getVersion());
+
+ country.setCountryname("美国4");
+ Assert.assertEquals(1, mapper.updateByPrimaryKey(country));
+
+ country = mapper.selectByPrimaryKey(174);
+ Assert.assertNotNull(country);
+ Assert.assertEquals(new Integer(4), country.getVersion());
+ } finally {
+ sqlSession.close();
+ }
+ }
+
class Key extends Country {
private String countrytel;
@@ -122,5 +160,4 @@ public void setCountrytel(String countrytel) {
this.countrytel = countrytel;
}
}
-
}
diff --git a/src/test/resources/CreateDB.sql b/src/test/resources/CreateDB.sql
index 6516427e4..d6300e91f 100644
--- a/src/test/resources/CreateDB.sql
+++ b/src/test/resources/CreateDB.sql
@@ -1,9 +1,10 @@
drop table country if exists;
create table country (
- id integer NOT NULL PRIMARY KEY,
+ id integer NOT NULL PRIMARY KEY,
countryname varchar(32),
- countrycode varchar(2) DEFAULT 'HH'
+ countrycode VARCHAR(2) DEFAULT 'HH',
+ version INTEGER DEFAULT 1 NOT NULL
);
create table country2 (
@@ -92,189 +93,189 @@ insert into user_login (logid,username,logindate,loginip) values (9,'test4','201
insert into user_login (logid,username,logindate,loginip) values (10,'test5','2014-11-21 12:00:00','192.168.1.123');
-insert into country (id, countryname, countrycode) values(1,'Angola','AO');
-insert into country (id, countryname, countrycode) values(2,'Afghanistan','AF');
-insert into country (id, countryname, countrycode) values(3,'Albania','AL');
-insert into country (id, countryname, countrycode) values(4,'Algeria','DZ');
-insert into country (id, countryname, countrycode) values(5,'Andorra','AD');
-insert into country (id, countryname, countrycode) values(6,'Anguilla','AI');
-insert into country (id, countryname, countrycode) values(7,'Antigua and Barbuda','AG');
-insert into country (id, countryname, countrycode) values(8,'Argentina','AR');
-insert into country (id, countryname, countrycode) values(9,'Armenia','AM');
-insert into country (id, countryname, countrycode) values(10,'Australia','AU');
-insert into country (id, countryname, countrycode) values(11,'Austria','AT');
-insert into country (id, countryname, countrycode) values(12,'Azerbaijan','AZ');
-insert into country (id, countryname, countrycode) values(13,'Bahamas','BS');
-insert into country (id, countryname, countrycode) values(14,'Bahrain','BH');
-insert into country (id, countryname, countrycode) values(15,'Bangladesh','BD');
-insert into country (id, countryname, countrycode) values(16,'Barbados','BB');
-insert into country (id, countryname, countrycode) values(17,'Belarus','BY');
-insert into country (id, countryname, countrycode) values(18,'Belgium','BE');
-insert into country (id, countryname, countrycode) values(19,'Belize','BZ');
-insert into country (id, countryname, countrycode) values(20,'Benin','BJ');
-insert into country (id, countryname, countrycode) values(21,'Bermuda Is.','BM');
-insert into country (id, countryname, countrycode) values(22,'Bolivia','BO');
-insert into country (id, countryname, countrycode) values(23,'Botswana','BW');
-insert into country (id, countryname, countrycode) values(24,'Brazil','BR');
-insert into country (id, countryname, countrycode) values(25,'Brunei','BN');
-insert into country (id, countryname, countrycode) values(26,'Bulgaria','BG');
-insert into country (id, countryname, countrycode) values(27,'Burkina-faso','BF');
-insert into country (id, countryname, countrycode) values(28,'Burma','MM');
-insert into country (id, countryname, countrycode) values(29,'Burundi','BI');
-insert into country (id, countryname, countrycode) values(30,'Cameroon','CM');
-insert into country (id, countryname, countrycode) values(31,'Canada','CA');
-insert into country (id, countryname, countrycode) values(32,'Central African Republic','CF');
-insert into country (id, countryname, countrycode) values(33,'Chad','TD');
-insert into country (id, countryname, countrycode) values(34,'Chile','CL');
-insert into country (id, countryname, countrycode) values(35,'China','CN');
-insert into country (id, countryname, countrycode) values(36,'Colombia','CO');
-insert into country (id, countryname, countrycode) values(37,'Congo','CG');
-insert into country (id, countryname, countrycode) values(38,'Cook Is.','CK');
-insert into country (id, countryname, countrycode) values(39,'Costa Rica','CR');
-insert into country (id, countryname, countrycode) values(40,'Cuba','CU');
-insert into country (id, countryname, countrycode) values(41,'Cyprus','CY');
-insert into country (id, countryname, countrycode) values(42,'Czech Republic','CZ');
-insert into country (id, countryname, countrycode) values(43,'Denmark','DK');
-insert into country (id, countryname, countrycode) values(44,'Djibouti','DJ');
-insert into country (id, countryname, countrycode) values(45,'Dominica Rep.','DO');
-insert into country (id, countryname, countrycode) values(46,'Ecuador','EC');
-insert into country (id, countryname, countrycode) values(47,'Egypt','EG');
-insert into country (id, countryname, countrycode) values(48,'EI Salvador','SV');
-insert into country (id, countryname, countrycode) values(49,'Estonia','EE');
-insert into country (id, countryname, countrycode) values(50,'Ethiopia','ET');
-insert into country (id, countryname, countrycode) values(51,'Fiji','FJ');
-insert into country (id, countryname, countrycode) values(52,'Finland','FI');
-insert into country (id, countryname, countrycode) values(53,'France','FR');
-insert into country (id, countryname, countrycode) values(54,'French Guiana','GF');
-insert into country (id, countryname, countrycode) values(55,'Gabon','GA');
-insert into country (id, countryname, countrycode) values(56,'Gambia','GM');
-insert into country (id, countryname, countrycode) values(57,'Georgia','GE');
-insert into country (id, countryname, countrycode) values(58,'Germany','DE');
-insert into country (id, countryname, countrycode) values(59,'Ghana','GH');
-insert into country (id, countryname, countrycode) values(60,'Gibraltar','GI');
-insert into country (id, countryname, countrycode) values(61,'Greece','GR');
-insert into country (id, countryname, countrycode) values(62,'Grenada','GD');
-insert into country (id, countryname, countrycode) values(63,'Guam','GU');
-insert into country (id, countryname, countrycode) values(64,'Guatemala','GT');
-insert into country (id, countryname, countrycode) values(65,'Guinea','GN');
-insert into country (id, countryname, countrycode) values(66,'Guyana','GY');
-insert into country (id, countryname, countrycode) values(67,'Haiti','HT');
-insert into country (id, countryname, countrycode) values(68,'Honduras','HN');
-insert into country (id, countryname, countrycode) values(69,'Hongkong','HK');
-insert into country (id, countryname, countrycode) values(70,'Hungary','HU');
-insert into country (id, countryname, countrycode) values(71,'Iceland','IS');
-insert into country (id, countryname, countrycode) values(72,'India','IN');
-insert into country (id, countryname, countrycode) values(73,'Indonesia','ID');
-insert into country (id, countryname, countrycode) values(74,'Iran','IR');
-insert into country (id, countryname, countrycode) values(75,'Iraq','IQ');
-insert into country (id, countryname, countrycode) values(76,'Ireland','IE');
-insert into country (id, countryname, countrycode) values(77,'Israel','IL');
-insert into country (id, countryname, countrycode) values(78,'Italy','IT');
-insert into country (id, countryname, countrycode) values(79,'Jamaica','JM');
-insert into country (id, countryname, countrycode) values(80,'Japan','JP');
-insert into country (id, countryname, countrycode) values(81,'Jordan','JO');
-insert into country (id, countryname, countrycode) values(82,'Kampuchea (Cambodia )','KH');
-insert into country (id, countryname, countrycode) values(83,'Kazakstan','KZ');
-insert into country (id, countryname, countrycode) values(84,'Kenya','KE');
-insert into country (id, countryname, countrycode) values(85,'Korea','KR');
-insert into country (id, countryname, countrycode) values(86,'Kuwait','KW');
-insert into country (id, countryname, countrycode) values(87,'Kyrgyzstan','KG');
-insert into country (id, countryname, countrycode) values(88,'Laos','LA');
-insert into country (id, countryname, countrycode) values(89,'Latvia','LV');
-insert into country (id, countryname, countrycode) values(90,'Lebanon','LB');
-insert into country (id, countryname, countrycode) values(91,'Lesotho','LS');
-insert into country (id, countryname, countrycode) values(92,'Liberia','LR');
-insert into country (id, countryname, countrycode) values(93,'Libya','LY');
-insert into country (id, countryname, countrycode) values(94,'Liechtenstein','LI');
-insert into country (id, countryname, countrycode) values(95,'Lithuania','LT');
-insert into country (id, countryname, countrycode) values(96,'Luxembourg','LU');
-insert into country (id, countryname, countrycode) values(97,'Macao','MO');
-insert into country (id, countryname, countrycode) values(98,'Madagascar','MG');
-insert into country (id, countryname, countrycode) values(99,'Malawi','MW');
-insert into country (id, countryname, countrycode) values(100,'Malaysia','MY');
-insert into country (id, countryname, countrycode) values(101,'Maldives','MV');
-insert into country (id, countryname, countrycode) values(102,'Mali','ML');
-insert into country (id, countryname, countrycode) values(103,'Malta','MT');
-insert into country (id, countryname, countrycode) values(104,'Mauritius','MU');
-insert into country (id, countryname, countrycode) values(105,'Mexico','MX');
-insert into country (id, countryname, countrycode) values(106,'Moldova, Republic of','MD');
-insert into country (id, countryname, countrycode) values(107,'Monaco','MC');
-insert into country (id, countryname, countrycode) values(108,'Mongolia','MN');
-insert into country (id, countryname, countrycode) values(109,'Montserrat Is','MS');
-insert into country (id, countryname, countrycode) values(110,'Morocco','MA');
-insert into country (id, countryname, countrycode) values(111,'Mozambique','MZ');
-insert into country (id, countryname, countrycode) values(112,'Namibia','NA');
-insert into country (id, countryname, countrycode) values(113,'Nauru','NR');
-insert into country (id, countryname, countrycode) values(114,'Nepal','NP');
-insert into country (id, countryname, countrycode) values(115,'Netherlands','NL');
-insert into country (id, countryname, countrycode) values(116,'New Zealand','NZ');
-insert into country (id, countryname, countrycode) values(117,'Nicaragua','NI');
-insert into country (id, countryname, countrycode) values(118,'Niger','NE');
-insert into country (id, countryname, countrycode) values(119,'Nigeria','NG');
-insert into country (id, countryname, countrycode) values(120,'North Korea','KP');
-insert into country (id, countryname, countrycode) values(121,'Norway','NO');
-insert into country (id, countryname, countrycode) values(122,'Oman','OM');
-insert into country (id, countryname, countrycode) values(123,'Pakistan','PK');
-insert into country (id, countryname, countrycode) values(124,'Panama','PA');
-insert into country (id, countryname, countrycode) values(125,'Papua New Cuinea','PG');
-insert into country (id, countryname, countrycode) values(126,'Paraguay','PY');
-insert into country (id, countryname, countrycode) values(127,'Peru','PE');
-insert into country (id, countryname, countrycode) values(128,'Philippines','PH');
-insert into country (id, countryname, countrycode) values(129,'Poland','PL');
-insert into country (id, countryname, countrycode) values(130,'French Polynesia','PF');
-insert into country (id, countryname, countrycode) values(131,'Portugal','PT');
-insert into country (id, countryname, countrycode) values(132,'Puerto Rico','PR');
-insert into country (id, countryname, countrycode) values(133,'Qatar','QA');
-insert into country (id, countryname, countrycode) values(134,'Romania','RO');
-insert into country (id, countryname, countrycode) values(135,'Russia','RU');
-insert into country (id, countryname, countrycode) values(136,'Saint Lueia','LC');
-insert into country (id, countryname, countrycode) values(137,'Saint Vincent','VC');
-insert into country (id, countryname, countrycode) values(138,'San Marino','SM');
-insert into country (id, countryname, countrycode) values(139,'Sao Tome and Principe','ST');
-insert into country (id, countryname, countrycode) values(140,'Saudi Arabia','SA');
-insert into country (id, countryname, countrycode) values(141,'Senegal','SN');
-insert into country (id, countryname, countrycode) values(142,'Seychelles','SC');
-insert into country (id, countryname, countrycode) values(143,'Sierra Leone','SL');
-insert into country (id, countryname, countrycode) values(144,'Singapore','SG');
-insert into country (id, countryname, countrycode) values(145,'Slovakia','SK');
-insert into country (id, countryname, countrycode) values(146,'Slovenia','SI');
-insert into country (id, countryname, countrycode) values(147,'Solomon Is','SB');
-insert into country (id, countryname, countrycode) values(148,'Somali','SO');
-insert into country (id, countryname, countrycode) values(149,'South Africa','ZA');
-insert into country (id, countryname, countrycode) values(150,'Spain','ES');
-insert into country (id, countryname, countrycode) values(151,'Sri Lanka','LK');
-insert into country (id, countryname, countrycode) values(152,'St.Lucia','LC');
-insert into country (id, countryname, countrycode) values(153,'St.Vincent','VC');
-insert into country (id, countryname, countrycode) values(154,'Sudan','SD');
-insert into country (id, countryname, countrycode) values(155,'Suriname','SR');
-insert into country (id, countryname, countrycode) values(156,'Swaziland','SZ');
-insert into country (id, countryname, countrycode) values(157,'Sweden','SE');
-insert into country (id, countryname, countrycode) values(158,'Switzerland','CH');
-insert into country (id, countryname, countrycode) values(159,'Syria','SY');
-insert into country (id, countryname, countrycode) values(160,'Taiwan','TW');
-insert into country (id, countryname, countrycode) values(161,'Tajikstan','TJ');
-insert into country (id, countryname, countrycode) values(162,'Tanzania','TZ');
-insert into country (id, countryname, countrycode) values(163,'Thailand','TH');
-insert into country (id, countryname, countrycode) values(164,'Togo','TG');
-insert into country (id, countryname, countrycode) values(165,'Tonga','TO');
-insert into country (id, countryname, countrycode) values(166,'Trinidad and Tobago','TT');
-insert into country (id, countryname, countrycode) values(167,'Tunisia','TN');
-insert into country (id, countryname, countrycode) values(168,'Turkey','TR');
-insert into country (id, countryname, countrycode) values(169,'Turkmenistan','TM');
-insert into country (id, countryname, countrycode) values(170,'Uganda','UG');
-insert into country (id, countryname, countrycode) values(171,'Ukraine','UA');
-insert into country (id, countryname, countrycode) values(172,'United Arab Emirates','AE');
-insert into country (id, countryname, countrycode) values(173,'United Kiongdom','GB');
-insert into country (id, countryname, countrycode) values(174,'United States of America','US');
-insert into country (id, countryname, countrycode) values(175,'Uruguay','UY');
-insert into country (id, countryname, countrycode) values(176,'Uzbekistan','UZ');
-insert into country (id, countryname, countrycode) values(177,'Venezuela','VE');
-insert into country (id, countryname, countrycode) values(178,'Vietnam','VN');
-insert into country (id, countryname, countrycode) values(179,'Yemen','YE');
-insert into country (id, countryname, countrycode) values(180,'Yugoslavia','YU');
-insert into country (id, countryname, countrycode) values(181,'Zimbabwe','ZW');
-insert into country (id, countryname, countrycode) values(182,'Zaire','ZR');
-insert into country (id, countryname, countrycode) values(183,'Zambia','ZM');
+INSERT INTO country (id, countryname, countrycode, version) VALUES (1, 'Angola', 'AO', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (2, 'Afghanistan', 'AF', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (3, 'Albania', 'AL', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (4, 'Algeria', 'DZ', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (5, 'Andorra', 'AD', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (6, 'Anguilla', 'AI', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (7, 'Antigua and Barbuda', 'AG', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (8, 'Argentina', 'AR', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (9, 'Armenia', 'AM', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (10, 'Australia', 'AU', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (11, 'Austria', 'AT', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (12, 'Azerbaijan', 'AZ', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (13, 'Bahamas', 'BS', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (14, 'Bahrain', 'BH', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (15, 'Bangladesh', 'BD', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (16, 'Barbados', 'BB', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (17, 'Belarus', 'BY', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (18, 'Belgium', 'BE', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (19, 'Belize', 'BZ', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (20, 'Benin', 'BJ', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (21, 'Bermuda Is.', 'BM', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (22, 'Bolivia', 'BO', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (23, 'Botswana', 'BW', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (24, 'Brazil', 'BR', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (25, 'Brunei', 'BN', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (26, 'Bulgaria', 'BG', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (27, 'Burkina-faso', 'BF', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (28, 'Burma', 'MM', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (29, 'Burundi', 'BI', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (30, 'Cameroon', 'CM', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (31, 'Canada', 'CA', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (32, 'Central African Republic', 'CF', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (33, 'Chad', 'TD', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (34, 'Chile', 'CL', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (35, 'China', 'CN', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (36, 'Colombia', 'CO', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (37, 'Congo', 'CG', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (38, 'Cook Is.', 'CK', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (39, 'Costa Rica', 'CR', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (40, 'Cuba', 'CU', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (41, 'Cyprus', 'CY', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (42, 'Czech Republic', 'CZ', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (43, 'Denmark', 'DK', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (44, 'Djibouti', 'DJ', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (45, 'Dominica Rep.', 'DO', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (46, 'Ecuador', 'EC', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (47, 'Egypt', 'EG', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (48, 'EI Salvador', 'SV', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (49, 'Estonia', 'EE', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (50, 'Ethiopia', 'ET', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (51, 'Fiji', 'FJ', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (52, 'Finland', 'FI', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (53, 'France', 'FR', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (54, 'French Guiana', 'GF', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (55, 'Gabon', 'GA', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (56, 'Gambia', 'GM', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (57, 'Georgia', 'GE', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (58, 'Germany', 'DE', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (59, 'Ghana', 'GH', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (60, 'Gibraltar', 'GI', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (61, 'Greece', 'GR', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (62, 'Grenada', 'GD', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (63, 'Guam', 'GU', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (64, 'Guatemala', 'GT', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (65, 'Guinea', 'GN', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (66, 'Guyana', 'GY', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (67, 'Haiti', 'HT', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (68, 'Honduras', 'HN', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (69, 'Hongkong', 'HK', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (70, 'Hungary', 'HU', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (71, 'Iceland', 'IS', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (72, 'India', 'IN', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (73, 'Indonesia', 'ID', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (74, 'Iran', 'IR', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (75, 'Iraq', 'IQ', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (76, 'Ireland', 'IE', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (77, 'Israel', 'IL', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (78, 'Italy', 'IT', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (79, 'Jamaica', 'JM', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (80, 'Japan', 'JP', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (81, 'Jordan', 'JO', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (82, 'Kampuchea (Cambodia )', 'KH', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (83, 'Kazakstan', 'KZ', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (84, 'Kenya', 'KE', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (85, 'Korea', 'KR', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (86, 'Kuwait', 'KW', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (87, 'Kyrgyzstan', 'KG', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (88, 'Laos', 'LA', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (89, 'Latvia', 'LV', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (90, 'Lebanon', 'LB', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (91, 'Lesotho', 'LS', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (92, 'Liberia', 'LR', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (93, 'Libya', 'LY', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (94, 'Liechtenstein', 'LI', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (95, 'Lithuania', 'LT', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (96, 'Luxembourg', 'LU', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (97, 'Macao', 'MO', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (98, 'Madagascar', 'MG', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (99, 'Malawi', 'MW', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (100, 'Malaysia', 'MY', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (101, 'Maldives', 'MV', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (102, 'Mali', 'ML', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (103, 'Malta', 'MT', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (104, 'Mauritius', 'MU', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (105, 'Mexico', 'MX', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (106, 'Moldova, Republic of', 'MD', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (107, 'Monaco', 'MC', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (108, 'Mongolia', 'MN', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (109, 'Montserrat Is', 'MS', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (110, 'Morocco', 'MA', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (111, 'Mozambique', 'MZ', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (112, 'Namibia', 'NA', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (113, 'Nauru', 'NR', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (114, 'Nepal', 'NP', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (115, 'Netherlands', 'NL', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (116, 'New Zealand', 'NZ', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (117, 'Nicaragua', 'NI', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (118, 'Niger', 'NE', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (119, 'Nigeria', 'NG', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (120, 'North Korea', 'KP', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (121, 'Norway', 'NO', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (122, 'Oman', 'OM', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (123, 'Pakistan', 'PK', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (124, 'Panama', 'PA', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (125, 'Papua New Cuinea', 'PG', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (126, 'Paraguay', 'PY', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (127, 'Peru', 'PE', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (128, 'Philippines', 'PH', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (129, 'Poland', 'PL', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (130, 'French Polynesia', 'PF', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (131, 'Portugal', 'PT', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (132, 'Puerto Rico', 'PR', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (133, 'Qatar', 'QA', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (134, 'Romania', 'RO', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (135, 'Russia', 'RU', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (136, 'Saint Lueia', 'LC', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (137, 'Saint Vincent', 'VC', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (138, 'San Marino', 'SM', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (139, 'Sao Tome and Principe', 'ST', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (140, 'Saudi Arabia', 'SA', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (141, 'Senegal', 'SN', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (142, 'Seychelles', 'SC', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (143, 'Sierra Leone', 'SL', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (144, 'Singapore', 'SG', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (145, 'Slovakia', 'SK', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (146, 'Slovenia', 'SI', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (147, 'Solomon Is', 'SB', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (148, 'Somali', 'SO', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (149, 'South Africa', 'ZA', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (150, 'Spain', 'ES', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (151, 'Sri Lanka', 'LK', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (152, 'St.Lucia', 'LC', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (153, 'St.Vincent', 'VC', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (154, 'Sudan', 'SD', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (155, 'Suriname', 'SR', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (156, 'Swaziland', 'SZ', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (157, 'Sweden', 'SE', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (158, 'Switzerland', 'CH', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (159, 'Syria', 'SY', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (160, 'Taiwan', 'TW', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (161, 'Tajikstan', 'TJ', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (162, 'Tanzania', 'TZ', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (163, 'Thailand', 'TH', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (164, 'Togo', 'TG', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (165, 'Tonga', 'TO', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (166, 'Trinidad and Tobago', 'TT', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (167, 'Tunisia', 'TN', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (168, 'Turkey', 'TR', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (169, 'Turkmenistan', 'TM', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (170, 'Uganda', 'UG', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (171, 'Ukraine', 'UA', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (172, 'United Arab Emirates', 'AE', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (173, 'United Kiongdom', 'GB', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (174, 'United States of America', 'US', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (175, 'Uruguay', 'UY', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (176, 'Uzbekistan', 'UZ', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (177, 'Venezuela', 'VE', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (178, 'Vietnam', 'VN', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (179, 'Yemen', 'YE', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (180, 'Yugoslavia', 'YU', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (181, 'Zimbabwe', 'ZW', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (182, 'Zaire', 'ZR', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (183, 'Zambia', 'ZM', 1);
diff --git a/src/test/resources/mybatis-java.xml b/src/test/resources/mybatis-java.xml
index df78ea3b6..cefaa41c2 100644
--- a/src/test/resources/mybatis-java.xml
+++ b/src/test/resources/mybatis-java.xml
@@ -74,6 +74,7 @@
+
From e9e7107de2f463fb452f83b6294ea96e181822ef Mon Sep 17 00:00:00 2001
From: isea533
Date: Tue, 2 Jan 2018 22:22:00 +0800
Subject: [PATCH 090/407] =?UTF-8?q?FieldHelper=20=E6=94=B9=E4=B8=BA?=
=?UTF-8?q?=E5=88=A4=E6=96=AD=20jdk6=E5=92=8C7=EF=BC=8C=E5=85=B6=E4=BB=96?=
=?UTF-8?q?=E4=B8=BA8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../tk/mybatis/mapper/mapperhelper/FieldHelper.java | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/main/java/tk/mybatis/mapper/mapperhelper/FieldHelper.java b/src/main/java/tk/mybatis/mapper/mapperhelper/FieldHelper.java
index f93aaeb4b..98b7cb4a9 100644
--- a/src/main/java/tk/mybatis/mapper/mapperhelper/FieldHelper.java
+++ b/src/main/java/tk/mybatis/mapper/mapperhelper/FieldHelper.java
@@ -47,10 +47,10 @@ public class FieldHelper {
static {
String version = System.getProperty("java.version");
- if (version.contains("1.8.")) {
- fieldHelper = new Jdk8FieldHelper();
- } else {
+ if (version.contains("1.6.") || version.contains("1.7.")) {
fieldHelper = new Jdk6_7FieldHelper();
+ } else {
+ fieldHelper = new Jdk8FieldHelper();
}
}
@@ -136,6 +136,7 @@ static class Jdk8FieldHelper implements IFieldHelper {
* @param entityClass
* @return
*/
+ @Override
public List getFields(Class> entityClass) {
List fields = _getFields(entityClass, null, null);
List properties = getProperties(entityClass);
@@ -175,7 +176,7 @@ private List _getFields(Class> entityClass, List fie
for (int i = 0; i < fields.length; i++) {
Field field = fields[i];
//排除静态字段,解决bug#2
- if (!Modifier.isStatic(field.getModifiers())) {
+ if (!Modifier.isStatic(field.getModifiers()) && !Modifier.isTransient(field.getModifiers())) {
if (level.intValue() != 0) {
//将父类的字段放在前面
fieldList.add(index, new EntityField(field, null));
@@ -202,6 +203,7 @@ private List _getFields(Class> entityClass, List fie
* @param entityClass
* @return
*/
+ @Override
public List getProperties(Class> entityClass) {
List entityFields = new ArrayList();
BeanInfo beanInfo = null;
@@ -238,6 +240,7 @@ public List getFields(Class> entityClass) {
* @param entityClass
* @return
*/
+ @Override
public List getProperties(Class> entityClass) {
Map> genericMap = _getGenericTypeMap(entityClass);
List entityFields = new ArrayList();
From 8e0362bad6eba660071fc2e91857117a9ea5a3b1 Mon Sep 17 00:00:00 2001
From: isea533
Date: Tue, 2 Jan 2018 22:22:27 +0800
Subject: [PATCH 091/407] =?UTF-8?q?useSimpleType=20=E9=BB=98=E8=AE=A4?=
=?UTF-8?q?=E6=94=B9=E4=B8=BA=20true,=20=E5=A2=9E=E5=8A=A0=20annotationAsS?=
=?UTF-8?q?impleType=20=E5=8F=82=E6=95=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../java/tk/mybatis/mapper/entity/Config.java | 19 ++++++++++++++++++-
.../mapper/mapperhelper/EntityHelper.java | 7 ++++++-
.../mybatis/mapper/mapper/MybatisHelper.java | 1 +
3 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/src/main/java/tk/mybatis/mapper/entity/Config.java b/src/main/java/tk/mybatis/mapper/entity/Config.java
index 6fd757372..83e41d891 100644
--- a/src/main/java/tk/mybatis/mapper/entity/Config.java
+++ b/src/main/java/tk/mybatis/mapper/entity/Config.java
@@ -47,7 +47,12 @@ public class Config {
//校验调用Example方法时,Example(entityClass)和Mapper是否一致
private boolean checkExampleEntityClass;
//使用简单类型
- private boolean useSimpleType;
+ //3.5.0 后默认值改为 true
+ private boolean useSimpleType = true;
+ /**
+ * @since 3.5.0
+ */
+ private boolean annotationAsSimpleType = false;
/**
* 是否支持方法上的注解,默认false
*/
@@ -184,6 +189,14 @@ public void setUUID(String UUID) {
this.UUID = UUID;
}
+ public boolean isAnnotationAsSimpleType() {
+ return annotationAsSimpleType;
+ }
+
+ public void setAnnotationAsSimpleType(boolean annotationAsSimpleType) {
+ this.annotationAsSimpleType = annotationAsSimpleType;
+ }
+
/**
* 获取SelectKey的Order
*
@@ -289,6 +302,10 @@ public void setProperties(Properties properties) {
if (StringUtil.isNotEmpty(useSimpleTypeStr)) {
this.useSimpleType = useSimpleTypeStr.equalsIgnoreCase("TRUE");
}
+ String annotationAsSimpleTypeStr = properties.getProperty("annotationAsSimpleType");
+ if (StringUtil.isNotEmpty(annotationAsSimpleTypeStr)) {
+ this.annotationAsSimpleType = annotationAsSimpleTypeStr.equalsIgnoreCase("TRUE");
+ }
//注册新的基本类型,以逗号隔开,使用全限定类名
String simpleTypes = properties.getProperty("simpleTypes");
if (StringUtil.isNotEmpty(simpleTypes)) {
diff --git a/src/main/java/tk/mybatis/mapper/mapperhelper/EntityHelper.java b/src/main/java/tk/mybatis/mapper/mapperhelper/EntityHelper.java
index fb7375f1b..093f6691a 100644
--- a/src/main/java/tk/mybatis/mapper/mapperhelper/EntityHelper.java
+++ b/src/main/java/tk/mybatis/mapper/mapperhelper/EntityHelper.java
@@ -39,6 +39,7 @@
import tk.mybatis.mapper.util.StringUtil;
import javax.persistence.*;
+import java.lang.annotation.Annotation;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@@ -224,7 +225,11 @@ public static synchronized void initEntityNameMap(Class> entityClass, Config c
}
for (EntityField field : fields) {
//如果启用了简单类型,就做简单类型校验,如果不是简单类型,直接跳过
- if(config.isUseSimpleType() && !SimpleTypeUtil.isSimpleType(field.getJavaType())){
+ //3.5.0 如果启用了枚举作为简单类型,就不会自动忽略枚举类型
+ if (config.isUseSimpleType() &&
+ !(SimpleTypeUtil.isSimpleType(field.getJavaType())
+ ||
+ (config.isAnnotationAsSimpleType() && Annotation.class.isAssignableFrom(field.getJavaType())))) {
continue;
}
processField(entityTable, style, field);
diff --git a/src/test/java/tk/mybatis/mapper/mapper/MybatisHelper.java b/src/test/java/tk/mybatis/mapper/mapper/MybatisHelper.java
index d781c540a..fcd8600e7 100644
--- a/src/test/java/tk/mybatis/mapper/mapper/MybatisHelper.java
+++ b/src/test/java/tk/mybatis/mapper/mapper/MybatisHelper.java
@@ -77,6 +77,7 @@ public class MybatisHelper {
config.setCheckExampleEntityClass(true);
//启用简单类型
config.setUseSimpleType(true);
+ config.setAnnotationAsSimpleType(true);
// 序列的获取规则,使用{num}格式化参数,默认值为{0}.nextval,针对Oracle
// 可选参数一共3个,对应0,1,2,分别为SequenceName,ColumnName, PropertyName
//config.setSeqFormat("NEXT VALUE FOR {0}");
From db970d5079baee595dd8e9a7743e30d46b4e4af9 Mon Sep 17 00:00:00 2001
From: isea533
Date: Tue, 2 Jan 2018 22:30:03 +0800
Subject: [PATCH 092/407] =?UTF-8?q?3.5.0-SNAPSHOT=20=E5=92=8C=20=E6=9B=B4?=
=?UTF-8?q?=E6=96=B0=E6=97=A5=E5=BF=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 2 +-
wiki/Changelog.md | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 8696db30a..04aa4fb48 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
tk.mybatismapper
- 3.4.6
+ 3.5.0-SNAPSHOTjarmapper
diff --git a/wiki/Changelog.md b/wiki/Changelog.md
index 020899b4f..2762244d9 100644
--- a/wiki/Changelog.md
+++ b/wiki/Changelog.md
@@ -1,5 +1,15 @@
# 更新日志
+## 3.5.0-SNAPSHOT
+
+- 兼容 mbg 1.3.6 版本。
+- `EntityColumn` 记录 `EntityField` 信息,方便后续扩展使用。
+- 新增 `selectOneByExample` 方法,必须保证返回值最多 1 个,否则抛出异常。
+- 针对 update 两个基本方法增加乐观锁功能,在实体类对版本字段增加 `@Version` 注解即可,默认支持 `Integer` 和 `Long` 类型,其他情况可以实现 `NextVersion` 接口并在注解中指定该实现,一个实体类中最多只能有一个加 `@Version` 注解的字段。
+- 3.4.0增加的 `useSimpleType` 默认值改为 `true`,默认忽略复杂类型的字段,复杂类型不需要加 `@Transient` 注解,具体类型可以参考 `SimpleTypeUtil` 类。
+- 新增 `annotationAsSimpleType` 参数,默认 `false`,设置为 `true` 后会把枚举作为简单类型对待,需要配合 `useSimpleType = true` 使用。
+- `FieldHelper` 改为判断当前jdk版本是否为6和7,其他情况按jdk8处理,因此支持jdk9+
+
## 3.4.6
- `Example` 新增 builder 模式(by [Ngone51](https://github.com/abel533/Mapper/commits?author=Ngone51))。
From 686001a341c84e5cf39a704dc0fce9b0df514898 Mon Sep 17 00:00:00 2001
From: isea533
Date: Sat, 6 Jan 2018 22:11:07 +0800
Subject: [PATCH 093/407] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20wrapKeyword=20?=
=?UTF-8?q?=E5=8F=82=E6=95=B0=EF=BC=8C=E8=87=AA=E5=8A=A8=E5=A4=84=E7=90=86?=
=?UTF-8?q?=E5=85=B3=E9=94=AE=E5=AD=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../java/tk/mybatis/mapper/entity/Config.java | 18 +++++++++++++++++-
.../mapper/mapperhelper/EntityHelper.java | 10 ++++++++--
2 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/src/main/java/tk/mybatis/mapper/entity/Config.java b/src/main/java/tk/mybatis/mapper/entity/Config.java
index 83e41d891..838421516 100644
--- a/src/main/java/tk/mybatis/mapper/entity/Config.java
+++ b/src/main/java/tk/mybatis/mapper/entity/Config.java
@@ -61,11 +61,14 @@ public class Config {
* 对于一般的getAllIfColumnNode,是否判断!='',默认不判断
*/
private boolean notEmpty = false;
-
/**
* 字段转换风格,默认驼峰转下划线
*/
private Style style;
+ /**
+ * 处理关键字,默认空,mysql可以设置为 `{0}`, sqlserver 为 [{0}],{0} 代表的列名
+ */
+ private String wrapKeyword = "";
public String getCatalog() {
return catalog;
@@ -189,6 +192,14 @@ public void setUUID(String UUID) {
this.UUID = UUID;
}
+ public String getWrapKeyword() {
+ return wrapKeyword;
+ }
+
+ public void setWrapKeyword(String wrapKeyword) {
+ this.wrapKeyword = wrapKeyword;
+ }
+
public boolean isAnnotationAsSimpleType() {
return annotationAsSimpleType;
}
@@ -322,5 +333,10 @@ public void setProperties(Properties properties) {
//默认驼峰
this.style = Style.camelhump;
}
+ //处理关键字
+ String wrapKeyword = properties.getProperty("wrapKeyword");
+ if (StringUtil.isNotEmpty(wrapKeyword)) {
+ this.wrapKeyword = wrapKeyword;
+ }
}
}
diff --git a/src/main/java/tk/mybatis/mapper/mapperhelper/EntityHelper.java b/src/main/java/tk/mybatis/mapper/mapperhelper/EntityHelper.java
index 093f6691a..34ffb3a40 100644
--- a/src/main/java/tk/mybatis/mapper/mapperhelper/EntityHelper.java
+++ b/src/main/java/tk/mybatis/mapper/mapperhelper/EntityHelper.java
@@ -36,10 +36,12 @@
import tk.mybatis.mapper.entity.EntityField;
import tk.mybatis.mapper.entity.EntityTable;
import tk.mybatis.mapper.util.SimpleTypeUtil;
+import tk.mybatis.mapper.util.SqlReservedWords;
import tk.mybatis.mapper.util.StringUtil;
import javax.persistence.*;
import java.lang.annotation.Annotation;
+import java.text.MessageFormat;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@@ -232,7 +234,7 @@ public static synchronized void initEntityNameMap(Class> entityClass, Config c
(config.isAnnotationAsSimpleType() && Annotation.class.isAssignableFrom(field.getJavaType())))) {
continue;
}
- processField(entityTable, style, field);
+ processField(entityTable, style, field, config.getWrapKeyword());
}
//当pk.size=0的时候使用所有列作为主键
if (entityTable.getEntityClassPKColumns().size() == 0) {
@@ -249,7 +251,7 @@ public static synchronized void initEntityNameMap(Class> entityClass, Config c
* @param style
* @param field
*/
- private static void processField(EntityTable entityTable, Style style, EntityField field) {
+ private static void processField(EntityTable entityTable, Style style, EntityField field, String wrapKeyword) {
//排除字段
if (field.isAnnotationPresent(Transient.class)) {
return;
@@ -287,6 +289,10 @@ private static void processField(EntityTable entityTable, Style style, EntityFie
if (StringUtil.isEmpty(columnName)) {
columnName = StringUtil.convertByStyle(field.getName(), style);
}
+ //自动处理关键字
+ if (StringUtil.isNotEmpty(wrapKeyword) && SqlReservedWords.containsWord(columnName)) {
+ columnName = MessageFormat.format(wrapKeyword, columnName);
+ }
entityColumn.setProperty(field.getName());
entityColumn.setColumn(columnName);
entityColumn.setJavaType(field.getJavaType());
From 0a447e1f722e89b2b509bcda11c7d0ab483a8f20 Mon Sep 17 00:00:00 2001
From: isea533
Date: Sun, 7 Jan 2018 11:04:32 +0800
Subject: [PATCH 094/407] config.setWrapKeyword("`{0}`")
---
src/test/java/tk/mybatis/mapper/mapper/MybatisHelper.java | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/test/java/tk/mybatis/mapper/mapper/MybatisHelper.java b/src/test/java/tk/mybatis/mapper/mapper/MybatisHelper.java
index fcd8600e7..c7073f9e1 100644
--- a/src/test/java/tk/mybatis/mapper/mapper/MybatisHelper.java
+++ b/src/test/java/tk/mybatis/mapper/mapper/MybatisHelper.java
@@ -88,6 +88,8 @@ public class MybatisHelper {
//config.setSchema("");
// 主键自增回写方法执行顺序,默认AFTER,可选值为(BEFORE|AFTER)
//config.setOrder("AFTER");
+ //自动关键字 - mysql
+ //config.setWrapKeyword("`{0}`");
//设置配置
mapperHelper.setConfig(config);
// 注册通用Mapper接口 - 可以自动注册继承的接口
From ec18d459eb283d6b4b5fabed838826ae23c8e1d8 Mon Sep 17 00:00:00 2001
From: isea533
Date: Sun, 7 Jan 2018 12:25:56 +0800
Subject: [PATCH 095/407] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20insertList=20?=
=?UTF-8?q?=E6=96=B9=E6=B3=95=EF=BC=8C=E8=BF=99=E4=B8=AA=E6=96=B9=E6=B3=95?=
=?UTF-8?q?=E4=B8=8D=E4=BC=9A=E8=BF=94=E5=9B=9E=E4=B8=BB=E9=94=AE=EF=BC=8C?=
=?UTF-8?q?=E9=9C=80=E8=A6=81=E5=9C=A8=E6=8F=92=E5=85=A5=E5=89=8D=E6=89=8B?=
=?UTF-8?q?=E5=8A=A8=E8=AE=BE=E7=BD=AE=E5=A5=BD=E6=89=80=E6=9C=89=E5=80=BC?=
=?UTF-8?q?=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../additional/insert/InsertListMapper.java | 50 +++++++++++++
.../additional/insert/InsertListProvider.java | 72 +++++++++++++++++++
2 files changed, 122 insertions(+)
create mode 100644 src/main/java/tk/mybatis/mapper/additional/insert/InsertListMapper.java
create mode 100644 src/main/java/tk/mybatis/mapper/additional/insert/InsertListProvider.java
diff --git a/src/main/java/tk/mybatis/mapper/additional/insert/InsertListMapper.java b/src/main/java/tk/mybatis/mapper/additional/insert/InsertListMapper.java
new file mode 100644
index 000000000..da05c631e
--- /dev/null
+++ b/src/main/java/tk/mybatis/mapper/additional/insert/InsertListMapper.java
@@ -0,0 +1,50 @@
+/*
+ * 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.additional.insert;
+
+import org.apache.ibatis.annotations.InsertProvider;
+
+import java.util.List;
+
+/**
+ * 通用Mapper接口,特殊方法,批量插入,支持批量插入的数据库都可以使用,例如mysql,h2等
+ *
+ * @param 不能为空
+ * @author liuzh
+ * @since 3.5.0
+ */
+public interface InsertListMapper {
+
+ /**
+ * 批量插入,支持批量插入的数据库可以使用,例如MySQL,H2等
+ *
+ * 不支持主键策略,插入前需要设置好主键的值
+ *
+ * @param recordList
+ * @return
+ */
+ @InsertProvider(type = InsertListProvider.class, method = "dynamicSQL")
+ int insertList(List recordList);
+}
\ No newline at end of file
diff --git a/src/main/java/tk/mybatis/mapper/additional/insert/InsertListProvider.java b/src/main/java/tk/mybatis/mapper/additional/insert/InsertListProvider.java
new file mode 100644
index 000000000..5204d4134
--- /dev/null
+++ b/src/main/java/tk/mybatis/mapper/additional/insert/InsertListProvider.java
@@ -0,0 +1,72 @@
+/*
+ * 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.additional.insert;
+
+import org.apache.ibatis.mapping.MappedStatement;
+import tk.mybatis.mapper.entity.EntityColumn;
+import tk.mybatis.mapper.mapperhelper.EntityHelper;
+import tk.mybatis.mapper.mapperhelper.MapperHelper;
+import tk.mybatis.mapper.mapperhelper.MapperTemplate;
+import tk.mybatis.mapper.mapperhelper.SqlHelper;
+
+import java.util.Set;
+
+/**
+ * @author liuzh
+ */
+public class InsertListProvider extends MapperTemplate {
+
+ public InsertListProvider(Class> mapperClass, MapperHelper mapperHelper) {
+ super(mapperClass, mapperHelper);
+ }
+
+ /**
+ * 批量插入
+ *
+ * @param ms
+ */
+ public String insertList(MappedStatement ms) {
+ final Class> entityClass = getEntityClass(ms);
+ //开始拼sql
+ StringBuilder sql = new StringBuilder();
+ sql.append(SqlHelper.insertIntoTable(entityClass, tableName(entityClass)));
+ sql.append(SqlHelper.insertColumns(entityClass, false, false, false));
+ sql.append(" VALUES ");
+ sql.append("");
+ sql.append("");
+ //获取全部列
+ Set columnList = EntityHelper.getColumns(entityClass);
+ //当某个列有主键策略时,不需要考虑他的属性是否为空,因为如果为空,一定会根据主键策略给他生成一个值
+ for (EntityColumn column : columnList) {
+ if (column.isInsertable()) {
+ sql.append(column.getColumnHolder("record") + ",");
+ }
+ }
+ sql.append("");
+ sql.append("");
+ return sql.toString();
+ }
+
+}
From 1e76bff8af1ed9f5d4188ba9ac92b0fba01198a2 Mon Sep 17 00:00:00 2001
From: isea533
Date: Sun, 7 Jan 2018 12:42:16 +0800
Subject: [PATCH 096/407] 3.5.0
---
pom.xml | 2 +-
wiki/Changelog.md | 25 ++++++++++++++++++++++---
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index 04aa4fb48..19634265b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
tk.mybatismapper
- 3.5.0-SNAPSHOT
+ 3.5.0jarmapper
diff --git a/wiki/Changelog.md b/wiki/Changelog.md
index 2762244d9..5c7247743 100644
--- a/wiki/Changelog.md
+++ b/wiki/Changelog.md
@@ -1,16 +1,35 @@
# 更新日志
-## 3.5.0-SNAPSHOT
+## 3.5.0 - 2018-01-08
- 兼容 mbg 1.3.6 版本。
- `EntityColumn` 记录 `EntityField` 信息,方便后续扩展使用。
-- 新增 `selectOneByExample` 方法,必须保证返回值最多 1 个,否则抛出异常。
- 针对 update 两个基本方法增加乐观锁功能,在实体类对版本字段增加 `@Version` 注解即可,默认支持 `Integer` 和 `Long` 类型,其他情况可以实现 `NextVersion` 接口并在注解中指定该实现,一个实体类中最多只能有一个加 `@Version` 注解的字段。
+
- 3.4.0增加的 `useSimpleType` 默认值改为 `true`,默认忽略复杂类型的字段,复杂类型不需要加 `@Transient` 注解,具体类型可以参考 `SimpleTypeUtil` 类。
- 新增 `annotationAsSimpleType` 参数,默认 `false`,设置为 `true` 后会把枚举作为简单类型对待,需要配合 `useSimpleType = true` 使用。
+- 新增 `wrapKeyword` 参数,配置后会自动处理关键字,可以配的值和数据库有关,例如 sqlserver 可以配置为 `[{0}]`,使用 `{0}` 替代原来的列名。
- `FieldHelper` 改为判断当前jdk版本是否为6和7,其他情况按jdk8处理,因此支持jdk9+
-## 3.4.6
+- 新增 `selectOneByExample` 方法,必须保证返回值最多 1 个,否则抛出异常。
+- 增加新的 `tk.mybatis.mapper.additional.insert.InsertListMapper`,这个批量插入方法不支持主键策略,不会返回自动生成的主键
+
+使用 `@Version` 注解的效果如下:
+
+```sql
+DEBUG [main] - ==> Preparing: UPDATE country SET countryname = ?,countrycode = ?,version = 2 WHERE id = ? AND version = ?
+DEBUG [main] - ==> Parameters: 美国2(String), US(String), 174(Integer), 1(Integer)
+```
+
+自动处理关键字代码:
+```java
+//自动处理关键字
+if (StringUtil.isNotEmpty(wrapKeyword) && SqlReservedWords.containsWord(columnName)) {
+ columnName = MessageFormat.format(wrapKeyword, columnName);
+}
+```
+
+## 3.4.6 - 2017-12-17
- `Example` 新增 builder 模式(by [Ngone51](https://github.com/abel533/Mapper/commits?author=Ngone51))。
- 设置下划线风格替换为驼峰风格的Pattern为StringUtil的静态变量(by [Ngone51](https://github.com/abel533/Mapper/commits?author=Ngone51))。
From 8ee61ec8d51ea38aab0e26df0995489cdba598a5 Mon Sep 17 00:00:00 2001
From: isea533
Date: Sun, 21 Jan 2018 14:42:41 +0800
Subject: [PATCH 097/407] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9=20java8=20?=
=?UTF-8?q?=E4=B8=AD=E7=9A=84=E6=97=A5=E6=9C=9F=E7=B1=BB=E5=9E=8B=E7=9A=84?=
=?UTF-8?q?=E6=94=AF=E6=8C=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../mybatis/mapper/util/SimpleTypeUtil.java | 29 +++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/src/main/java/tk/mybatis/mapper/util/SimpleTypeUtil.java b/src/main/java/tk/mybatis/mapper/util/SimpleTypeUtil.java
index 7c38b9701..eb335aa9c 100644
--- a/src/main/java/tk/mybatis/mapper/util/SimpleTypeUtil.java
+++ b/src/main/java/tk/mybatis/mapper/util/SimpleTypeUtil.java
@@ -36,6 +36,18 @@
* 参考 org.apache.ibatis.type.SimpleTypeRegistry
*/
public class SimpleTypeUtil {
+ public static final String[] JAVA8_DATE_TIME = {
+ "java.time.Instant",
+ "java.time.LocalDateTime",
+ "java.time.LocalDate",
+ "java.time.LocalTime",
+ "java.time.OffsetDateTime",
+ "java.time.OffsetTime",
+ "java.time.ZonedDateTime",
+ "java.time.Year",
+ "java.time.Month",
+ "java.time.YearMonth"
+ };
private static final Set> SIMPLE_TYPE_SET = new HashSet>();
/**
@@ -56,6 +68,10 @@ public class SimpleTypeUtil {
SIMPLE_TYPE_SET.add(Class.class);
SIMPLE_TYPE_SET.add(BigInteger.class);
SIMPLE_TYPE_SET.add(BigDecimal.class);
+ //反射方式设置 java8 中的日期类型
+ for (String time : JAVA8_DATE_TIME) {
+ registerSimpleTypeSilence(time);
+ }
}
/**
@@ -85,6 +101,19 @@ public static void registerSimpleType(String classes){
}
}
+ /**
+ * 注册新的类型,不存在时不抛出异常
+ *
+ * @param clazz
+ */
+ private static void registerSimpleTypeSilence(String clazz) {
+ try {
+ SIMPLE_TYPE_SET.add(Class.forName(clazz));
+ } catch (ClassNotFoundException e) {
+ //ignore
+ }
+ }
+
/*
* Tells us if the class passed in is a known common type
*
From 565558f3fc786259d39bdcdfe94500cae343e03a Mon Sep 17 00:00:00 2001
From: isea533
Date: Sun, 21 Jan 2018 14:48:43 +0800
Subject: [PATCH 098/407] =?UTF-8?q?3.5.0=20=E7=89=88=E6=9C=AC=E4=B8=AD?=
=?UTF-8?q?=E7=9A=84=E5=8F=82=E6=95=B0=20annotationAsSimpleType=20?=
=?UTF-8?q?=E5=90=8D=E5=AD=97=E9=94=99=E4=BA=86=EF=BC=8C=E7=8E=B0=E5=9C=A8?=
=?UTF-8?q?=E6=94=B9=E4=B8=BA=20enumAsSimpleType=EF=BC=8C=E7=94=A8?=
=?UTF-8?q?=E4=BA=8E=E9=85=8D=E7=BD=AE=E6=98=AF=E5=90=A6=E5=B0=86=E6=9E=9A?=
=?UTF-8?q?=E4=B8=BE=E7=B1=BB=E5=9E=8B=E5=BD=93=E6=88=90=E5=9F=BA=E6=9C=AC?=
=?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=AF=B9=E5=BE=85=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../java/tk/mybatis/mapper/entity/Config.java | 26 +++++++++----------
.../mapper/mapperhelper/EntityHelper.java | 3 +--
.../provider/base/BaseDeleteProvider.java | 2 ++
.../mybatis/mapper/mapper/MybatisHelper.java | 2 +-
4 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/src/main/java/tk/mybatis/mapper/entity/Config.java b/src/main/java/tk/mybatis/mapper/entity/Config.java
index 838421516..abd2704e6 100644
--- a/src/main/java/tk/mybatis/mapper/entity/Config.java
+++ b/src/main/java/tk/mybatis/mapper/entity/Config.java
@@ -48,11 +48,11 @@ public class Config {
private boolean checkExampleEntityClass;
//使用简单类型
//3.5.0 后默认值改为 true
- private boolean useSimpleType = true;
+ private boolean useSimpleType = true;
/**
* @since 3.5.0
*/
- private boolean annotationAsSimpleType = false;
+ private boolean enumAsSimpleType = false;
/**
* 是否支持方法上的注解,默认false
*/
@@ -200,14 +200,6 @@ public void setWrapKeyword(String wrapKeyword) {
this.wrapKeyword = wrapKeyword;
}
- public boolean isAnnotationAsSimpleType() {
- return annotationAsSimpleType;
- }
-
- public void setAnnotationAsSimpleType(boolean annotationAsSimpleType) {
- this.annotationAsSimpleType = annotationAsSimpleType;
- }
-
/**
* 获取SelectKey的Order
*
@@ -237,6 +229,14 @@ public void setEnableMethodAnnotation(boolean enableMethodAnnotation) {
this.enableMethodAnnotation = enableMethodAnnotation;
}
+ public boolean isEnumAsSimpleType() {
+ return enumAsSimpleType;
+ }
+
+ public void setEnumAsSimpleType(boolean enumAsSimpleType) {
+ this.enumAsSimpleType = enumAsSimpleType;
+ }
+
public boolean isNotEmpty() {
return notEmpty;
}
@@ -313,9 +313,9 @@ public void setProperties(Properties properties) {
if (StringUtil.isNotEmpty(useSimpleTypeStr)) {
this.useSimpleType = useSimpleTypeStr.equalsIgnoreCase("TRUE");
}
- String annotationAsSimpleTypeStr = properties.getProperty("annotationAsSimpleType");
- if (StringUtil.isNotEmpty(annotationAsSimpleTypeStr)) {
- this.annotationAsSimpleType = annotationAsSimpleTypeStr.equalsIgnoreCase("TRUE");
+ String enumAsSimpleTypeStr = properties.getProperty("enumAsSimpleType");
+ if (StringUtil.isNotEmpty(enumAsSimpleTypeStr)) {
+ this.enumAsSimpleType = enumAsSimpleTypeStr.equalsIgnoreCase("TRUE");
}
//注册新的基本类型,以逗号隔开,使用全限定类名
String simpleTypes = properties.getProperty("simpleTypes");
diff --git a/src/main/java/tk/mybatis/mapper/mapperhelper/EntityHelper.java b/src/main/java/tk/mybatis/mapper/mapperhelper/EntityHelper.java
index 34ffb3a40..ac3963577 100644
--- a/src/main/java/tk/mybatis/mapper/mapperhelper/EntityHelper.java
+++ b/src/main/java/tk/mybatis/mapper/mapperhelper/EntityHelper.java
@@ -40,7 +40,6 @@
import tk.mybatis.mapper.util.StringUtil;
import javax.persistence.*;
-import java.lang.annotation.Annotation;
import java.text.MessageFormat;
import java.util.LinkedHashSet;
import java.util.List;
@@ -231,7 +230,7 @@ public static synchronized void initEntityNameMap(Class> entityClass, Config c
if (config.isUseSimpleType() &&
!(SimpleTypeUtil.isSimpleType(field.getJavaType())
||
- (config.isAnnotationAsSimpleType() && Annotation.class.isAssignableFrom(field.getJavaType())))) {
+ (config.isEnumAsSimpleType() && Enum.class.isAssignableFrom(field.getJavaType())))) {
continue;
}
processField(entityTable, style, field, config.getWrapKeyword());
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 09788fd60..f41a24bd4 100644
--- a/src/main/java/tk/mybatis/mapper/provider/base/BaseDeleteProvider.java
+++ b/src/main/java/tk/mybatis/mapper/provider/base/BaseDeleteProvider.java
@@ -50,6 +50,7 @@ public String delete(MappedStatement ms) {
Class> entityClass = getEntityClass(ms);
StringBuilder sql = new StringBuilder();
sql.append(SqlHelper.deleteFromTable(entityClass, tableName(entityClass)));
+ //TODO 增加 @Version 支持
sql.append(SqlHelper.whereAllIfColumns(entityClass, isNotEmpty()));
return sql.toString();
}
@@ -63,6 +64,7 @@ public String deleteByPrimaryKey(MappedStatement ms) {
final Class> entityClass = getEntityClass(ms);
StringBuilder sql = new StringBuilder();
sql.append(SqlHelper.deleteFromTable(entityClass, tableName(entityClass)));
+ //TODO 增加 @Version 支持
sql.append(SqlHelper.wherePKColumns(entityClass));
return sql.toString();
}
diff --git a/src/test/java/tk/mybatis/mapper/mapper/MybatisHelper.java b/src/test/java/tk/mybatis/mapper/mapper/MybatisHelper.java
index c7073f9e1..12face7a1 100644
--- a/src/test/java/tk/mybatis/mapper/mapper/MybatisHelper.java
+++ b/src/test/java/tk/mybatis/mapper/mapper/MybatisHelper.java
@@ -77,7 +77,7 @@ public class MybatisHelper {
config.setCheckExampleEntityClass(true);
//启用简单类型
config.setUseSimpleType(true);
- config.setAnnotationAsSimpleType(true);
+ config.setEnumAsSimpleType(true);
// 序列的获取规则,使用{num}格式化参数,默认值为{0}.nextval,针对Oracle
// 可选参数一共3个,对应0,1,2,分别为SequenceName,ColumnName, PropertyName
//config.setSeqFormat("NEXT VALUE FOR {0}");
From fc01cf2652a7544992f26babeeebe6911da25b8f Mon Sep 17 00:00:00 2001
From: isea533
Date: Sun, 21 Jan 2018 15:15:58 +0800
Subject: [PATCH 099/407] =?UTF-8?q?delete=20=E5=92=8C=20deleteByPrimaryKey?=
=?UTF-8?q?=20=E5=A2=9E=E5=8A=A0=E5=AF=B9=E4=B9=90=E8=A7=82=E9=94=81?=
=?UTF-8?q?=E6=B3=A8=E8=A7=A3=20`@Version`=20=E7=9A=84=E6=94=AF=E6=8C=81?=
=?UTF-8?q?=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 2 +-
.../mapper/mapperhelper/SqlHelper.java | 54 ++++++++++++++----
.../provider/base/BaseDeleteProvider.java | 6 +-
.../test/country/TestDeleteByPrimaryKey.java | 56 +++++++++++++++++++
wiki/Changelog.md | 51 +++++++++++++++++
5 files changed, 153 insertions(+), 16 deletions(-)
diff --git a/pom.xml b/pom.xml
index 19634265b..05a05ed3c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
tk.mybatismapper
- 3.5.0
+ 3.5.1-betajarmapper
diff --git a/src/main/java/tk/mybatis/mapper/mapperhelper/SqlHelper.java b/src/main/java/tk/mybatis/mapper/mapperhelper/SqlHelper.java
index e7ccaef71..f100db6a7 100644
--- a/src/main/java/tk/mybatis/mapper/mapperhelper/SqlHelper.java
+++ b/src/main/java/tk/mybatis/mapper/mapperhelper/SqlHelper.java
@@ -506,17 +506,7 @@ public static String wherePKColumns(Class> entityClass, boolean useVersion) {
sql.append(" AND " + column.getColumnEqualsHolder());
}
if (useVersion) {
- columnList = EntityHelper.getColumns(entityClass);
- boolean hasVersion = false;
- for (EntityColumn column : columnList) {
- if (column.getEntityField().isAnnotationPresent(Version.class)) {
- if (hasVersion) {
- throw new VersionException(entityClass.getCanonicalName() + " 中包含多个带有 @Version 注解的字段,一个类中只能存在一个带有 @Version 注解的字段!");
- }
- hasVersion = true;
- sql.append(" AND " + column.getColumnEqualsHolder());
- }
- }
+ sql.append(whereVersion(entityClass));
}
sql.append("");
return sql.toString();
@@ -526,21 +516,61 @@ public static String wherePKColumns(Class> entityClass, boolean useVersion) {
* where所有列的条件,会判断是否!=null
*
* @param entityClass
+ * @param empty
* @return
*/
public static String whereAllIfColumns(Class> entityClass, boolean empty) {
+ return whereAllIfColumns(entityClass, empty, false);
+ }
+
+ /**
+ * where所有列的条件,会判断是否!=null
+ *
+ * @param entityClass
+ * @param empty
+ * @param useVersion
+ * @return
+ */
+ public static String whereAllIfColumns(Class> entityClass, boolean empty, boolean useVersion) {
StringBuilder sql = new StringBuilder();
sql.append("");
//获取全部列
Set columnList = EntityHelper.getColumns(entityClass);
//当某个列有主键策略时,不需要考虑他的属性是否为空,因为如果为空,一定会根据主键策略给他生成一个值
for (EntityColumn column : columnList) {
- sql.append(getIfNotNull(column, " AND " + column.getColumnEqualsHolder(), empty));
+ if (!useVersion || !column.getEntityField().isAnnotationPresent(Version.class)) {
+ sql.append(getIfNotNull(column, " AND " + column.getColumnEqualsHolder(), empty));
+ }
+ }
+ if (useVersion) {
+ sql.append(whereVersion(entityClass));
}
sql.append("");
return sql.toString();
}
+ /**
+ * 乐观锁字段条件
+ *
+ * @param entityClass
+ * @return
+ */
+ public static String whereVersion(Class> entityClass) {
+ Set columnList = EntityHelper.getColumns(entityClass);
+ boolean hasVersion = false;
+ String result = "";
+ for (EntityColumn column : columnList) {
+ if (column.getEntityField().isAnnotationPresent(Version.class)) {
+ if (hasVersion) {
+ throw new VersionException(entityClass.getCanonicalName() + " 中包含多个带有 @Version 注解的字段,一个类中只能存在一个带有 @Version 注解的字段!");
+ }
+ hasVersion = true;
+ result = " AND " + column.getColumnEqualsHolder();
+ }
+ }
+ return result;
+ }
+
/**
* 获取默认的orderBy,通过注解设置的
*
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 f41a24bd4..4c059de5f 100644
--- a/src/main/java/tk/mybatis/mapper/provider/base/BaseDeleteProvider.java
+++ b/src/main/java/tk/mybatis/mapper/provider/base/BaseDeleteProvider.java
@@ -51,7 +51,7 @@ public String delete(MappedStatement ms) {
StringBuilder sql = new StringBuilder();
sql.append(SqlHelper.deleteFromTable(entityClass, tableName(entityClass)));
//TODO 增加 @Version 支持
- sql.append(SqlHelper.whereAllIfColumns(entityClass, isNotEmpty()));
+ sql.append(SqlHelper.whereAllIfColumns(entityClass, isNotEmpty(), true));
return sql.toString();
}
@@ -64,8 +64,8 @@ public String deleteByPrimaryKey(MappedStatement ms) {
final Class> entityClass = getEntityClass(ms);
StringBuilder sql = new StringBuilder();
sql.append(SqlHelper.deleteFromTable(entityClass, tableName(entityClass)));
- //TODO 增加 @Version 支持
- sql.append(SqlHelper.wherePKColumns(entityClass));
+ //增加 @Version 乐观锁支持
+ sql.append(SqlHelper.wherePKColumns(entityClass, true));
return sql.toString();
}
}
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 488931d52..e76fdde60 100644
--- a/src/test/java/tk/mybatis/mapper/test/country/TestDeleteByPrimaryKey.java
+++ b/src/test/java/tk/mybatis/mapper/test/country/TestDeleteByPrimaryKey.java
@@ -28,8 +28,10 @@
import org.junit.Assert;
import org.junit.Test;
import tk.mybatis.mapper.mapper.CountryMapper;
+import tk.mybatis.mapper.mapper.CountryVersionMapper;
import tk.mybatis.mapper.mapper.MybatisHelper;
import tk.mybatis.mapper.model.Country;
+import tk.mybatis.mapper.model.CountryVersion;
import java.util.HashMap;
import java.util.Map;
@@ -151,6 +153,60 @@ public void testDynamicDeleteException() {
}
}
+ /**
+ * 乐观锁删除
+ */
+ @Test
+ public void testDeleteByVersion() {
+ SqlSession sqlSession = MybatisHelper.getSqlSession();
+ try {
+ CountryVersionMapper mapper = sqlSession.getMapper(CountryVersionMapper.class);
+ CountryVersion countryVersion = new CountryVersion();
+ countryVersion.setId(100);
+
+ //没有指定版本时删除不了
+ Assert.assertEquals(0, mapper.delete(countryVersion));
+
+ //版本不对的时候的时候删除不了
+ countryVersion.setVersion(2);
+ Assert.assertEquals(0, mapper.delete(countryVersion));
+
+ //版本正确的时候可以真正删除
+ countryVersion.setVersion(1);
+ Assert.assertEquals(1, mapper.delete(countryVersion));
+ } finally {
+ sqlSession.rollback();
+ sqlSession.close();
+ }
+ }
+
+ /**
+ * 乐观锁删除
+ */
+ @Test
+ public void testDeleteByPrimaryKeyAndVersion() {
+ SqlSession sqlSession = MybatisHelper.getSqlSession();
+ try {
+ CountryVersionMapper mapper = sqlSession.getMapper(CountryVersionMapper.class);
+ //根据主键删除,没有指定版本时删除不了
+ Assert.assertEquals(0, mapper.deleteByPrimaryKey(100));
+
+ CountryVersion countryVersion = new CountryVersion();
+ countryVersion.setId(100);
+
+ //版本不对的时候的时候删除不了
+ countryVersion.setVersion(2);
+ Assert.assertEquals(0, mapper.deleteByPrimaryKey(countryVersion));
+
+ //版本正确的时候可以真正删除
+ countryVersion.setVersion(1);
+ Assert.assertEquals(1, mapper.deleteByPrimaryKey(countryVersion));
+ } finally {
+ sqlSession.rollback();
+ sqlSession.close();
+ }
+ }
+
class Key {
}
diff --git a/wiki/Changelog.md b/wiki/Changelog.md
index 5c7247743..1ec90446a 100644
--- a/wiki/Changelog.md
+++ b/wiki/Changelog.md
@@ -1,5 +1,56 @@
# 更新日志
+## 3.5.1-beta - 2018-01-21
+
+#### 1. `delete` 和 `deleteByPrimaryKey` 增加对乐观锁注解 `@Version` 的支持。
+
+测试用例如下:
+```java
+/**
+ * 乐观锁删除
+ */
+@Test
+public void testDeleteByPrimaryKeyAndVersion() {
+ SqlSession sqlSession = MybatisHelper.getSqlSession();
+ try {
+ CountryVersionMapper mapper = sqlSession.getMapper(CountryVersionMapper.class);
+ //根据主键删除,没有指定版本时删除不了
+ Assert.assertEquals(0, mapper.deleteByPrimaryKey(100));
+
+ CountryVersion countryVersion = new CountryVersion();
+ countryVersion.setId(100);
+ countryVersion.setVersion(2);
+ //版本不对的时候的时候删除不了
+ Assert.assertEquals(0, mapper.deleteByPrimaryKey(countryVersion));
+
+ countryVersion.setId(100);
+ countryVersion.setVersion(1);
+ //版本正确的时候可以真正删除
+ Assert.assertEquals(1, mapper.deleteByPrimaryKey(countryVersion));
+ } finally {
+ sqlSession.rollback();
+ sqlSession.close();
+ }
+}
+```
+日志如下:
+```
+DEBUG [main] - ==> Preparing: DELETE FROM country WHERE id = ? AND version = ?
+DEBUG [main] - ==> Parameters: 100(Integer), 100(Integer)
+DEBUG [main] - <== Updates: 0
+DEBUG [main] - ==> Preparing: DELETE FROM country WHERE id = ? AND version = ?
+DEBUG [main] - ==> Parameters: 100(Integer), 2(Integer)
+DEBUG [main] - <== Updates: 0
+DEBUG [main] - ==> Preparing: DELETE FROM country WHERE id = ? AND version = ?
+DEBUG [main] - ==> Parameters: 100(Integer), 1(Integer)
+DEBUG [main] - <== Updates: 1
+```
+**特别注意:** 上面测试用例已经展示了增加乐观锁后的参数如何传递,当主键多个值或者使用乐观锁的时候就需要通过实体(Map也可以)传递多个参数值。和之前的 update 一样,需要自己对执行结果进行判断来判断是否执行成功。
+
+#### 2. 3.5.0 版本中的参数 `annotationAsSimpleType` 名字错了,现在改为 `enumAsSimpleType`,用于配置是否将枚举类型当成基本类型对待。
+
+#### 3. `SimpleTypeUtil` 增加对 java8 中的日期类型的支持。
+
## 3.5.0 - 2018-01-08
- 兼容 mbg 1.3.6 版本。
From d5367d2d1698e41ff1f654254d82f4f35e27cc25 Mon Sep 17 00:00:00 2001
From: Yin Xu
Date: Tue, 16 Jan 2018 16:07:24 +0800
Subject: [PATCH 100/407] =?UTF-8?q?=E6=A8=A1=E4=BB=BFExample.Builder?=
=?UTF-8?q?=E4=B8=ADSqls=E6=9E=84=E5=BB=BA=E6=96=B9=E6=B3=95=20=E6=B7=BB?=
=?UTF-8?q?=E5=8A=A0WeekendSqls=E9=87=8D=E8=BD=BD=E6=96=B9=E6=B3=95=20?=
=?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95=E7=B1=BB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 2 +-
.../tk/mybatis/mapper/entity/Example.java | 27 +++++++-
.../mapper/test/weekend/WeekendSqlsTest.java | 69 +++++++++++++++++++
3 files changed, 94 insertions(+), 4 deletions(-)
create mode 100644 src/test/java/tk/mybatis/mapper/test/weekend/WeekendSqlsTest.java
diff --git a/pom.xml b/pom.xml
index 19634265b..8bb4b5058 100644
--- a/pom.xml
+++ b/pom.xml
@@ -108,7 +108,7 @@
tk.mybatismapper-weekend
- 1.0.0
+ 1.1.0compiletrue
diff --git a/src/main/java/tk/mybatis/mapper/entity/Example.java b/src/main/java/tk/mybatis/mapper/entity/Example.java
index 4600cfb0a..2a16b530d 100644
--- a/src/main/java/tk/mybatis/mapper/entity/Example.java
+++ b/src/main/java/tk/mybatis/mapper/entity/Example.java
@@ -31,6 +31,7 @@
import tk.mybatis.mapper.mapperhelper.EntityHelper;
import tk.mybatis.mapper.util.Sqls;
import tk.mybatis.mapper.util.StringUtil;
+import tk.mybatis.mapper.weekend.WeekendSqls;
import java.util.*;
@@ -1041,22 +1042,42 @@ public Builder where(Sqls sqls) {
Sqls.Criteria criteria = sqls.getCriteria();
criteria.setAndOr("and");
this.sqlsCriteria.add(criteria);
- return this;
+ return this;
+ }
+
+ public Builder where(WeekendSqls 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;
+ return this;
}
+ public Builder andWhere(WeekendSqls 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;
+ return this;
+ }
+
+ public Builder orWhere(WeekendSqls sqls) {
+ Sqls.Criteria criteria = sqls.getCriteria();
+ criteria.setAndOr("or");
+ this.sqlsCriteria.add(criteria);
+ return this;
}
public Builder orderBy(String... properties) {
diff --git a/src/test/java/tk/mybatis/mapper/test/weekend/WeekendSqlsTest.java b/src/test/java/tk/mybatis/mapper/test/weekend/WeekendSqlsTest.java
new file mode 100644
index 000000000..e6065f6d8
--- /dev/null
+++ b/src/test/java/tk/mybatis/mapper/test/weekend/WeekendSqlsTest.java
@@ -0,0 +1,69 @@
+package tk.mybatis.mapper.test.weekend;
+
+/*
+import org.apache.ibatis.session.SqlSession;
+import org.junit.Assert;
+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 tk.mybatis.mapper.weekend.WeekendSqls;
+
+import java.util.List;
+*/
+
+/**
+ * 测试WeekendSql构建者模式类 由于方法引用需要jdk8
+ * 执行该测试的时候需要临时将pom.xml中maven-compiler-plugin插件jdk编译等级调整为1.8
+ * 为了防止jdk6编译等级打包出错,将测试用例全部注释
+ *
-
-
-
- dev
-
- true
-
-
-
- release
-
-
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
- 2.9
-
-
- package
-
- jar
-
-
- -Xdoclint:none
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-gpg-plugin
-
-
- sign-artifacts
- verify
-
- sign
-
-
-
-
-
-
-
-
- oss
- https://oss.sonatype.org/content/repositories/snapshots/
-
-
- oss
- https://oss.sonatype.org/service/local/staging/deploy/maven2/
-
-
-
-
diff --git a/src/main/java/tk/mybatis/mapper/additional/insert/InsertListMapper.java b/src/main/java/tk/mybatis/mapper/additional/insert/InsertListMapper.java
deleted file mode 100644
index da05c631e..000000000
--- a/src/main/java/tk/mybatis/mapper/additional/insert/InsertListMapper.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.additional.insert;
-
-import org.apache.ibatis.annotations.InsertProvider;
-
-import java.util.List;
-
-/**
- * 通用Mapper接口,特殊方法,批量插入,支持批量插入的数据库都可以使用,例如mysql,h2等
- *
- * @param 不能为空
- * @author liuzh
- * @since 3.5.0
- */
-public interface InsertListMapper {
-
- /**
- * 批量插入,支持批量插入的数据库可以使用,例如MySQL,H2等
- *
- * 不支持主键策略,插入前需要设置好主键的值
- *
- * @param recordList
- * @return
- */
- @InsertProvider(type = InsertListProvider.class, method = "dynamicSQL")
- int insertList(List recordList);
-}
\ No newline at end of file
diff --git a/src/main/java/tk/mybatis/mapper/additional/insert/InsertListProvider.java b/src/main/java/tk/mybatis/mapper/additional/insert/InsertListProvider.java
deleted file mode 100644
index 5204d4134..000000000
--- a/src/main/java/tk/mybatis/mapper/additional/insert/InsertListProvider.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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.additional.insert;
-
-import org.apache.ibatis.mapping.MappedStatement;
-import tk.mybatis.mapper.entity.EntityColumn;
-import tk.mybatis.mapper.mapperhelper.EntityHelper;
-import tk.mybatis.mapper.mapperhelper.MapperHelper;
-import tk.mybatis.mapper.mapperhelper.MapperTemplate;
-import tk.mybatis.mapper.mapperhelper.SqlHelper;
-
-import java.util.Set;
-
-/**
- * @author liuzh
- */
-public class InsertListProvider extends MapperTemplate {
-
- public InsertListProvider(Class> mapperClass, MapperHelper mapperHelper) {
- super(mapperClass, mapperHelper);
- }
-
- /**
- * 批量插入
- *
- * @param ms
- */
- public String insertList(MappedStatement ms) {
- final Class> entityClass = getEntityClass(ms);
- //开始拼sql
- StringBuilder sql = new StringBuilder();
- sql.append(SqlHelper.insertIntoTable(entityClass, tableName(entityClass)));
- sql.append(SqlHelper.insertColumns(entityClass, false, false, false));
- sql.append(" VALUES ");
- sql.append("");
- sql.append("");
- //获取全部列
- Set columnList = EntityHelper.getColumns(entityClass);
- //当某个列有主键策略时,不需要考虑他的属性是否为空,因为如果为空,一定会根据主键策略给他生成一个值
- for (EntityColumn column : columnList) {
- if (column.isInsertable()) {
- sql.append(column.getColumnHolder("record") + ",");
- }
- }
- sql.append("");
- sql.append("");
- return sql.toString();
- }
-
-}
diff --git a/src/main/java/tk/mybatis/mapper/entity/Config.java b/src/main/java/tk/mybatis/mapper/entity/Config.java
index abd2704e6..31f2fb85b 100644
--- a/src/main/java/tk/mybatis/mapper/entity/Config.java
+++ b/src/main/java/tk/mybatis/mapper/entity/Config.java
@@ -30,6 +30,8 @@
import tk.mybatis.mapper.util.SimpleTypeUtil;
import tk.mybatis.mapper.util.StringUtil;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Properties;
/**
@@ -38,6 +40,9 @@
* @author liuzh
*/
public class Config {
+ public static final String PREFIX = "mapper";
+
+ private List mappers = new ArrayList();
private String UUID;
private String IDENTITY;
private boolean BEFORE;
@@ -262,6 +267,38 @@ public void setOrder(String order) {
this.BEFORE = "BEFORE".equalsIgnoreCase(order);
}
+ public String getIdentity() {
+ return getIDENTITY();
+ }
+
+ public void setIdentity(String identity) {
+ setIDENTITY(identity);
+ }
+
+ public List getMappers() {
+ return mappers;
+ }
+
+ public void setMappers(List mappers) {
+ this.mappers = mappers;
+ }
+
+ public String getUuid() {
+ return getUUID();
+ }
+
+ public void setUuid(String uuid) {
+ setUUID(uuid);
+ }
+
+ public boolean isBefore() {
+ return isBEFORE();
+ }
+
+ public void setBefore(boolean before) {
+ setBEFORE(before);
+ }
+
/**
* 配置属性
*
diff --git a/src/main/java/tk/mybatis/mapper/generator/FalseMethodPlugin.java b/src/main/java/tk/mybatis/mapper/generator/FalseMethodPlugin.java
deleted file mode 100644
index ceea47bfb..000000000
--- a/src/main/java/tk/mybatis/mapper/generator/FalseMethodPlugin.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * 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.api.IntrospectedTable;
-import org.mybatis.generator.api.PluginAdapter;
-import org.mybatis.generator.api.dom.java.Interface;
-import org.mybatis.generator.api.dom.java.Method;
-import org.mybatis.generator.api.dom.java.TopLevelClass;
-import org.mybatis.generator.api.dom.xml.XmlElement;
-
-import java.util.List;
-
-/**
- * 禁用大多数方法
- *
- * @author liuzh
- */
-public class FalseMethodPlugin extends PluginAdapter {
-
- @Override
- public boolean validate(List warnings) {
- return true;
- }
-
- //下面所有return false的方法都不生成。这些都是基础的CRUD方法,使用通用Mapper实现
- @Override
- public boolean clientDeleteByPrimaryKeyMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
- return false;
- }
-
- @Override
- public boolean clientInsertMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
- return false;
- }
-
- @Override
- public boolean clientInsertSelectiveMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
- return false;
- }
-
- @Override
- public boolean clientSelectByPrimaryKeyMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
- return false;
- }
-
- @Override
- public boolean clientUpdateByPrimaryKeySelectiveMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
- return false;
- }
-
- @Override
- public boolean clientUpdateByPrimaryKeyWithBLOBsMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
- return false;
- }
-
- @Override
- public boolean clientUpdateByPrimaryKeyWithoutBLOBsMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
- return false;
- }
-
- @Override
- public boolean clientDeleteByPrimaryKeyMethodGenerated(Method method, Interface interfaze, IntrospectedTable introspectedTable) {
- return false;
- }
-
- @Override
- public boolean clientInsertMethodGenerated(Method method, Interface interfaze, IntrospectedTable introspectedTable) {
- return false;
- }
-
- @Override
- public boolean clientInsertSelectiveMethodGenerated(Method method, Interface interfaze, IntrospectedTable introspectedTable) {
- return false;
- }
-
- @Override
- public boolean clientSelectAllMethodGenerated(Method method, Interface interfaze, IntrospectedTable introspectedTable) {
- return false;
- }
-
- @Override
- public boolean clientSelectAllMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
- return false;
- }
-
- @Override
- public boolean clientSelectByPrimaryKeyMethodGenerated(Method method, Interface interfaze, IntrospectedTable introspectedTable) {
- return false;
- }
-
- @Override
- public boolean clientUpdateByPrimaryKeySelectiveMethodGenerated(Method method, Interface interfaze, IntrospectedTable introspectedTable) {
- return false;
- }
-
- @Override
- public boolean clientUpdateByPrimaryKeyWithBLOBsMethodGenerated(Method method, Interface interfaze, IntrospectedTable introspectedTable) {
- return false;
- }
-
- @Override
- public boolean clientUpdateByPrimaryKeyWithoutBLOBsMethodGenerated(Method method, Interface interfaze, IntrospectedTable introspectedTable) {
- return false;
- }
-
- @Override
- public boolean sqlMapDeleteByPrimaryKeyElementGenerated(XmlElement element, IntrospectedTable introspectedTable) {
- return false;
- }
-
- @Override
- public boolean sqlMapInsertElementGenerated(XmlElement element, IntrospectedTable introspectedTable) {
- return false;
- }
-
- @Override
- public boolean sqlMapInsertSelectiveElementGenerated(XmlElement element, IntrospectedTable introspectedTable) {
- return false;
- }
-
- @Override
- public boolean sqlMapSelectAllElementGenerated(XmlElement element, IntrospectedTable introspectedTable) {
- return false;
- }
-
- @Override
- public boolean sqlMapSelectByPrimaryKeyElementGenerated(XmlElement element, IntrospectedTable introspectedTable) {
- return false;
- }
-
- @Override
- public boolean sqlMapUpdateByPrimaryKeySelectiveElementGenerated(XmlElement element, IntrospectedTable introspectedTable) {
- return false;
- }
-
- @Override
- public boolean sqlMapUpdateByPrimaryKeyWithBLOBsElementGenerated(XmlElement element, IntrospectedTable introspectedTable) {
- return false;
- }
-
- @Override
- public boolean sqlMapUpdateByPrimaryKeyWithoutBLOBsElementGenerated(XmlElement element, IntrospectedTable introspectedTable) {
- return false;
- }
-
- @Override
- public boolean providerGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
- return false;
- }
-
- @Override
- public boolean providerApplyWhereMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
- return false;
- }
-
- @Override
- public boolean providerInsertSelectiveMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
- return false;
- }
-
- @Override
- public boolean providerUpdateByPrimaryKeySelectiveMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
- return false;
- }
-
-}
diff --git a/src/main/java/tk/mybatis/mapper/generator/MapperCommentGenerator.java b/src/main/java/tk/mybatis/mapper/generator/MapperCommentGenerator.java
deleted file mode 100644
index 638d3bf13..000000000
--- a/src/main/java/tk/mybatis/mapper/generator/MapperCommentGenerator.java
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * 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.api.CommentGenerator;
-import org.mybatis.generator.api.IntrospectedColumn;
-import org.mybatis.generator.api.IntrospectedTable;
-import org.mybatis.generator.api.dom.java.*;
-import org.mybatis.generator.api.dom.xml.TextElement;
-import org.mybatis.generator.api.dom.xml.XmlElement;
-import org.mybatis.generator.config.MergeConstants;
-import org.mybatis.generator.internal.util.StringUtility;
-
-import java.text.MessageFormat;
-import java.util.Properties;
-import java.util.Set;
-
-public class MapperCommentGenerator implements CommentGenerator {
- //开始的分隔符,例如mysql为`,sqlserver为[
- private String beginningDelimiter = "";
- //结束的分隔符,例如mysql为`,sqlserver为]
- private String endingDelimiter = "";
- //强制生成注解
- private boolean forceAnnotation;
-
- public MapperCommentGenerator() {
- super();
- }
-
- @Override
- public void addJavaFileComment(CompilationUnit compilationUnit) {
- return;
- }
-
- /**
- * xml中的注释
- *
- * @param xmlElement
- */
- @Override
- public void addComment(XmlElement xmlElement) {
- xmlElement.addElement(new TextElement(""));
- }
-
- @Override
- public void addRootComment(XmlElement rootElement) {
- return;
- }
-
- @Override
- public void addConfigurationProperties(Properties properties) {
- String beginningDelimiter = properties.getProperty("beginningDelimiter");
- if (StringUtility.stringHasValue(beginningDelimiter)) {
- this.beginningDelimiter = beginningDelimiter;
- }
- String endingDelimiter = properties.getProperty("endingDelimiter");
- if (StringUtility.stringHasValue(endingDelimiter)) {
- this.endingDelimiter = endingDelimiter;
- }
- String forceAnnotation = properties.getProperty("forceAnnotation");
- if (StringUtility.stringHasValue(forceAnnotation)) {
- this.forceAnnotation = forceAnnotation.equalsIgnoreCase("TRUE");
- }
- }
-
- public String getDelimiterName(String name) {
- StringBuilder nameBuilder = new StringBuilder();
- nameBuilder.append(beginningDelimiter);
- nameBuilder.append(name);
- nameBuilder.append(endingDelimiter);
- return nameBuilder.toString();
- }
-
- /**
- * 删除标记
- *
- * @param javaElement
- * @param markAsDoNotDelete
- */
- protected void addJavadocTag(JavaElement javaElement, boolean markAsDoNotDelete) {
- StringBuilder sb = new StringBuilder();
- sb.append(" * ");
- sb.append(MergeConstants.NEW_ELEMENT_TAG);
- if (markAsDoNotDelete) {
- sb.append(" do_not_delete_during_merge");
- }
- javaElement.addJavaDocLine(sb.toString());
- }
-
- /**
- * Example使用
- *
- * @param innerClass
- * @param introspectedTable
- */
- @Override
- public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable) {
- }
-
- @Override
- public void addEnumComment(InnerEnum innerEnum, IntrospectedTable introspectedTable) {
- }
-
- /**
- * 给字段添加数据库备注
- *
- * @param field
- * @param introspectedTable
- * @param introspectedColumn
- */
- @Override
- public void addFieldComment(Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
- if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
- field.addJavaDocLine("/**");
- StringBuilder sb = new StringBuilder();
- sb.append(" * ");
- sb.append(introspectedColumn.getRemarks());
- field.addJavaDocLine(sb.toString());
- field.addJavaDocLine(" */");
- }
- //添加注解
- if (field.isTransient()) {
- //@Column
- field.addAnnotation("@Transient");
- }
- for (IntrospectedColumn column : introspectedTable.getPrimaryKeyColumns()) {
- if (introspectedColumn == column) {
- field.addAnnotation("@Id");
- break;
- }
- }
- String column = introspectedColumn.getActualColumnName();
- if (StringUtility.stringContainsSpace(column) || introspectedTable.getTableConfiguration().isAllColumnDelimitingEnabled()) {
- column = introspectedColumn.getContext().getBeginningDelimiter()
- + column
- + introspectedColumn.getContext().getEndingDelimiter();
- }
- if (!column.equals(introspectedColumn.getJavaProperty())) {
- //@Column
- field.addAnnotation("@Column(name = \"" + getDelimiterName(column) + "\")");
- } else if (StringUtility.stringHasValue(beginningDelimiter) || StringUtility.stringHasValue(endingDelimiter)) {
- field.addAnnotation("@Column(name = \"" + getDelimiterName(column) + "\")");
- } else if (forceAnnotation) {
- field.addAnnotation("@Column(name = \"" + getDelimiterName(column) + "\")");
- }
- if (introspectedColumn.isIdentity()) {
- if (introspectedTable.getTableConfiguration().getGeneratedKey().getRuntimeSqlStatement().equals("JDBC")) {
- field.addAnnotation("@GeneratedValue(generator = \"JDBC\")");
- } else {
- field.addAnnotation("@GeneratedValue(strategy = GenerationType.IDENTITY)");
- }
- } else if (introspectedColumn.isSequenceColumn()) {
- //在 Oracle 中,如果需要是 SEQ_TABLENAME,那么可以配置为 select SEQ_{1} from dual
- String tableName = introspectedTable.getFullyQualifiedTableNameAtRuntime();
- String sql = MessageFormat.format(introspectedTable.getTableConfiguration().getGeneratedKey().getRuntimeSqlStatement(), tableName, tableName.toUpperCase());
- field.addAnnotation("@GeneratedValue(strategy = GenerationType.IDENTITY, generator = \"" + sql + "\")");
- }
- }
-
- /**
- * Example使用
- *
- * @param field
- * @param introspectedTable
- */
- @Override
- public void addFieldComment(Field field, IntrospectedTable introspectedTable) {
- }
-
- @Override
- public void addModelClassComment(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
-
- }
-
- /**
- * @param method
- * @param introspectedTable
- */
- @Override
- public void addGeneralMethodComment(Method method, IntrospectedTable introspectedTable) {
- }
-
- /**
- * getter方法注释
- *
- * @param method
- * @param introspectedTable
- * @param introspectedColumn
- */
- @Override
- public void addGetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
- StringBuilder sb = new StringBuilder();
- method.addJavaDocLine("/**");
- if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
- sb.append(" * 获取");
- sb.append(introspectedColumn.getRemarks());
- method.addJavaDocLine(sb.toString());
- method.addJavaDocLine(" *");
- }
- sb.setLength(0);
- sb.append(" * @return ");
- sb.append(introspectedColumn.getActualColumnName());
- if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
- sb.append(" - ");
- sb.append(introspectedColumn.getRemarks());
- }
- method.addJavaDocLine(sb.toString());
- method.addJavaDocLine(" */");
- }
-
- /**
- * setter方法注释
- *
- * @param method
- * @param introspectedTable
- * @param introspectedColumn
- */
- @Override
- public void addSetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
- StringBuilder sb = new StringBuilder();
- method.addJavaDocLine("/**");
- if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
- sb.append(" * 设置");
- sb.append(introspectedColumn.getRemarks());
- method.addJavaDocLine(sb.toString());
- method.addJavaDocLine(" *");
- }
- Parameter parm = method.getParameters().get(0);
- sb.setLength(0);
- sb.append(" * @param ");
- sb.append(parm.getName());
- if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
- sb.append(" ");
- sb.append(introspectedColumn.getRemarks());
- }
- method.addJavaDocLine(sb.toString());
- method.addJavaDocLine(" */");
- }
-
- /**
- * Example使用
- *
- * @param innerClass
- * @param introspectedTable
- * @param markAsDoNotDelete
- */
- @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/main/java/tk/mybatis/mapper/generator/MapperPlugin.java b/src/main/java/tk/mybatis/mapper/generator/MapperPlugin.java
deleted file mode 100644
index 5cb256c60..000000000
--- a/src/main/java/tk/mybatis/mapper/generator/MapperPlugin.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * 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.api.IntrospectedTable;
-import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
-import org.mybatis.generator.api.dom.java.Interface;
-import org.mybatis.generator.api.dom.java.TopLevelClass;
-import org.mybatis.generator.config.CommentGeneratorConfiguration;
-import org.mybatis.generator.config.Context;
-import org.mybatis.generator.internal.util.StringUtility;
-import tk.mybatis.mapper.MapperException;
-
-import java.util.HashSet;
-import java.util.Properties;
-import java.util.Set;
-
-/**
- * 通用Mapper生成器插件
- *
- * @author liuzh
- */
-public class MapperPlugin extends FalseMethodPlugin {
- private Set mappers = new HashSet();
- private boolean caseSensitive = false;
- private boolean useMapperCommentGenerator = true;
- //开始的分隔符,例如mysql为`,sqlserver为[
- private String beginningDelimiter = "";
- //结束的分隔符,例如mysql为`,sqlserver为]
- private String endingDelimiter = "";
- //数据库模式
- private String schema;
- //注释生成器
- private CommentGeneratorConfiguration commentCfg;
- //强制生成注解
- private boolean forceAnnotation;
-
- public String getDelimiterName(String name) {
- StringBuilder nameBuilder = new StringBuilder();
- if (StringUtility.stringHasValue(schema)) {
- nameBuilder.append(schema);
- nameBuilder.append(".");
- }
- nameBuilder.append(beginningDelimiter);
- nameBuilder.append(name);
- nameBuilder.append(endingDelimiter);
- return nameBuilder.toString();
- }
-
- /**
- * 生成的Mapper接口
- *
- * @param interfaze
- * @param topLevelClass
- * @param introspectedTable
- * @return
- */
- @Override
- public boolean clientGenerated(Interface interfaze, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
- //获取实体类
- FullyQualifiedJavaType entityType = new FullyQualifiedJavaType(introspectedTable.getBaseRecordType());
- //import接口
- for (String mapper : mappers) {
- interfaze.addImportedType(new FullyQualifiedJavaType(mapper));
- interfaze.addSuperInterface(new FullyQualifiedJavaType(mapper + "<" + entityType.getShortName() + ">"));
- }
- //import实体类
- interfaze.addImportedType(entityType);
- return true;
- }
-
- /**
- * 处理实体类的包和@Table注解
- *
- * @param topLevelClass
- * @param introspectedTable
- */
- private void processEntityClass(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
- //引入JPA注解
- topLevelClass.addImportedType("javax.persistence.*");
- String tableName = introspectedTable.getFullyQualifiedTableNameAtRuntime();
- //如果包含空格,或者需要分隔符,需要完善
- if (StringUtility.stringContainsSpace(tableName)) {
- tableName = context.getBeginningDelimiter()
- + tableName
- + context.getEndingDelimiter();
- }
- //是否忽略大小写,对于区分大小写的数据库,会有用
- if (caseSensitive && !topLevelClass.getType().getShortName().equals(tableName)) {
- topLevelClass.addAnnotation("@Table(name = \"" + getDelimiterName(tableName) + "\")");
- } else if (!topLevelClass.getType().getShortName().equalsIgnoreCase(tableName)) {
- topLevelClass.addAnnotation("@Table(name = \"" + getDelimiterName(tableName) + "\")");
- } else if (StringUtility.stringHasValue(schema)
- || StringUtility.stringHasValue(beginningDelimiter)
- || StringUtility.stringHasValue(endingDelimiter)) {
- topLevelClass.addAnnotation("@Table(name = \"" + getDelimiterName(tableName) + "\")");
- } else if (forceAnnotation) {
- topLevelClass.addAnnotation("@Table(name = \"" + getDelimiterName(tableName) + "\")");
- }
- }
-
- /**
- * 生成基础实体类
- *
- * @param topLevelClass
- * @param introspectedTable
- * @return
- */
- @Override
- public boolean modelBaseRecordClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
- processEntityClass(topLevelClass, introspectedTable);
- return true;
- }
-
- /**
- * 生成实体类注解KEY对象
- *
- * @param topLevelClass
- * @param introspectedTable
- * @return
- */
- @Override
- public boolean modelPrimaryKeyClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
- processEntityClass(topLevelClass, introspectedTable);
- return true;
- }
-
- /**
- * 生成带BLOB字段的对象
- *
- * @param topLevelClass
- * @param introspectedTable
- * @return
- */
- @Override
- public boolean modelRecordWithBLOBsClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
- processEntityClass(topLevelClass, introspectedTable);
- return false;
- }
-
-
- @Override
- public void setContext(Context context) {
- super.setContext(context);
- //设置默认的注释生成器
- useMapperCommentGenerator = !"FALSE".equalsIgnoreCase(context.getProperty("useMapperCommentGenerator"));
- if (useMapperCommentGenerator) {
- commentCfg = new CommentGeneratorConfiguration();
- commentCfg.setConfigurationType(MapperCommentGenerator.class.getCanonicalName());
- context.setCommentGeneratorConfiguration(commentCfg);
- }
- //支持oracle获取注释#114
- context.getJdbcConnectionConfiguration().addProperty("remarksReporting", "true");
- }
-
- @Override
- public void setProperties(Properties properties) {
- super.setProperties(properties);
- String mappers = this.properties.getProperty("mappers");
- if (StringUtility.stringHasValue(mappers)) {
- for (String mapper : mappers.split(",")) {
- this.mappers.add(mapper);
- }
- } else {
- throw new MapperException("Mapper插件缺少必要的mappers属性!");
- }
- String caseSensitive = this.properties.getProperty("caseSensitive");
- if (StringUtility.stringHasValue(caseSensitive)) {
- this.caseSensitive = caseSensitive.equalsIgnoreCase("TRUE");
- }
- String forceAnnotation = this.properties.getProperty("forceAnnotation");
- if (StringUtility.stringHasValue(forceAnnotation)) {
- if (useMapperCommentGenerator) {
- commentCfg.addProperty("forceAnnotation", forceAnnotation);
- }
- this.forceAnnotation = forceAnnotation.equalsIgnoreCase("TRUE");
- }
- String beginningDelimiter = this.properties.getProperty("beginningDelimiter");
- if (StringUtility.stringHasValue(beginningDelimiter)) {
- this.beginningDelimiter = beginningDelimiter;
- }
- String endingDelimiter = this.properties.getProperty("endingDelimiter");
- if (StringUtility.stringHasValue(endingDelimiter)) {
- this.endingDelimiter = endingDelimiter;
- }
- String schema = this.properties.getProperty("schema");
- if (StringUtility.stringHasValue(schema)) {
- this.schema = schema;
- }
- if (useMapperCommentGenerator) {
- commentCfg.addProperty("beginningDelimiter", this.beginningDelimiter);
- commentCfg.addProperty("endingDelimiter", this.endingDelimiter);
- }
- }
-}
diff --git a/src/main/java/tk/mybatis/mapper/generator/TemplateFilePlugin.java b/src/main/java/tk/mybatis/mapper/generator/TemplateFilePlugin.java
deleted file mode 100644
index 183268e44..000000000
--- a/src/main/java/tk/mybatis/mapper/generator/TemplateFilePlugin.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * 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.api.GeneratedJavaFile;
-import org.mybatis.generator.api.IntrospectedColumn;
-import org.mybatis.generator.api.IntrospectedTable;
-import org.mybatis.generator.api.PluginAdapter;
-import org.mybatis.generator.api.dom.java.Field;
-import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
-import org.mybatis.generator.api.dom.java.JavaVisibility;
-import org.mybatis.generator.internal.ObjectFactory;
-import org.mybatis.generator.internal.util.StringUtility;
-import tk.mybatis.mapper.generator.file.GenerateByListTemplateFile;
-import tk.mybatis.mapper.generator.file.GenerateByTemplateFile;
-import tk.mybatis.mapper.generator.formatter.ListTemplateFormatter;
-import tk.mybatis.mapper.generator.formatter.TemplateFormatter;
-import tk.mybatis.mapper.generator.model.TableClass;
-import tk.mybatis.mapper.generator.model.TableColumnBuilder;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.util.*;
-
-/**
- * 每一个模板都需要配置一个插件,可以配置多个
- *
- *
- * @author liuzh
- * @since 2016-09-04 09:57
- */
-public class TkMyBatis3Impl extends IntrospectedTableMyBatis3Impl {
-
- @Override
- protected String calculateMyBatis3XmlMapperFileName() {
- StringBuilder sb = new StringBuilder();
- if (stringHasValue(tableConfiguration.getMapperName())) {
- String mapperName = tableConfiguration.getMapperName();
- int ind = mapperName.lastIndexOf('.');
- if (ind != -1) {
- mapperName = mapperName.substring(ind + 1);
- }
- //支持mapperName = "{0}Dao" 等用法
- sb.append(MessageFormat.format(mapperName, fullyQualifiedTable.getDomainObjectName()));
- sb.append(".xml"); //$NON-NLS-1$
- } else {
- sb.append(fullyQualifiedTable.getDomainObjectName());
- sb.append("Mapper.xml"); //$NON-NLS-1$
- }
- return sb.toString();
- }
-
- @Override
- protected void calculateJavaClientAttributes() {
- if (context.getJavaClientGeneratorConfiguration() == null) {
- return;
- }
-
- StringBuilder sb = new StringBuilder();
- sb.append(calculateJavaClientImplementationPackage());
- sb.append('.');
- sb.append(fullyQualifiedTable.getDomainObjectName());
- sb.append("DAOImpl"); //$NON-NLS-1$
- setDAOImplementationType(sb.toString());
-
- sb.setLength(0);
- sb.append(calculateJavaClientInterfacePackage());
- sb.append('.');
- sb.append(fullyQualifiedTable.getDomainObjectName());
- sb.append("DAO"); //$NON-NLS-1$
- setDAOInterfaceType(sb.toString());
-
- sb.setLength(0);
- sb.append(calculateJavaClientInterfacePackage());
- sb.append('.');
- if (stringHasValue(tableConfiguration.getMapperName())) {
- //支持mapperName = "{0}Dao" 等用法
- sb.append(MessageFormat.format(tableConfiguration.getMapperName(), fullyQualifiedTable.getDomainObjectName()));
- } else {
- sb.append(fullyQualifiedTable.getDomainObjectName());
- sb.append("Mapper"); //$NON-NLS-1$
- }
- setMyBatis3JavaMapperType(sb.toString());
-
- sb.setLength(0);
- sb.append(calculateJavaClientInterfacePackage());
- sb.append('.');
- if (stringHasValue(tableConfiguration.getSqlProviderName())) {
- //支持mapperName = "{0}SqlProvider" 等用法
- sb.append(MessageFormat.format(tableConfiguration.getSqlProviderName(), fullyQualifiedTable.getDomainObjectName()));
- } else {
- sb.append(fullyQualifiedTable.getDomainObjectName());
- sb.append("SqlProvider"); //$NON-NLS-1$
- }
- setMyBatis3SqlProviderType(sb.toString());
- }
-}
diff --git a/src/main/java/tk/mybatis/mapper/generator/TkMyBatis3SimpleImpl.java b/src/main/java/tk/mybatis/mapper/generator/TkMyBatis3SimpleImpl.java
deleted file mode 100644
index 455b1e247..000000000
--- a/src/main/java/tk/mybatis/mapper/generator/TkMyBatis3SimpleImpl.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * 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;
-
-import java.text.MessageFormat;
-
-import static org.mybatis.generator.internal.util.StringUtility.stringHasValue;
-
-/**
- * 可以通过MBG1.3.4+版本提供的table元素的mapperName属性设置统一的名称,使用{0}作为实体类名的占位符。
- *
- *
- * @author liuzh
- * @since 2016-09-04 09:57
- */
-public class TkMyBatis3SimpleImpl extends IntrospectedTableMyBatis3SimpleImpl {
-
- @Override
- protected String calculateMyBatis3XmlMapperFileName() {
- StringBuilder sb = new StringBuilder();
- if (stringHasValue(tableConfiguration.getMapperName())) {
- String mapperName = tableConfiguration.getMapperName();
- int ind = mapperName.lastIndexOf('.');
- if (ind != -1) {
- mapperName = mapperName.substring(ind + 1);
- }
- //支持mapperName = "{0}Dao" 等用法
- sb.append(MessageFormat.format(mapperName, fullyQualifiedTable.getDomainObjectName()));
- sb.append(".xml"); //$NON-NLS-1$
- } else {
- sb.append(fullyQualifiedTable.getDomainObjectName());
- sb.append("Mapper.xml"); //$NON-NLS-1$
- }
- return sb.toString();
- }
-
- @Override
- protected void calculateJavaClientAttributes() {
- if (context.getJavaClientGeneratorConfiguration() == null) {
- return;
- }
-
- StringBuilder sb = new StringBuilder();
- sb.append(calculateJavaClientImplementationPackage());
- sb.append('.');
- sb.append(fullyQualifiedTable.getDomainObjectName());
- sb.append("DAOImpl"); //$NON-NLS-1$
- setDAOImplementationType(sb.toString());
-
- sb.setLength(0);
- sb.append(calculateJavaClientInterfacePackage());
- sb.append('.');
- sb.append(fullyQualifiedTable.getDomainObjectName());
- sb.append("DAO"); //$NON-NLS-1$
- setDAOInterfaceType(sb.toString());
-
- sb.setLength(0);
- sb.append(calculateJavaClientInterfacePackage());
- sb.append('.');
- if (stringHasValue(tableConfiguration.getMapperName())) {
- //支持mapperName = "{0}Dao" 等用法
- sb.append(MessageFormat.format(tableConfiguration.getMapperName(), fullyQualifiedTable.getDomainObjectName()));
- } else {
- sb.append(fullyQualifiedTable.getDomainObjectName());
- sb.append("Mapper"); //$NON-NLS-1$
- }
- setMyBatis3JavaMapperType(sb.toString());
-
- sb.setLength(0);
- sb.append(calculateJavaClientInterfacePackage());
- sb.append('.');
- if (stringHasValue(tableConfiguration.getSqlProviderName())) {
- //支持mapperName = "{0}SqlProvider" 等用法
- sb.append(MessageFormat.format(tableConfiguration.getSqlProviderName(), fullyQualifiedTable.getDomainObjectName()));
- } else {
- sb.append(fullyQualifiedTable.getDomainObjectName());
- sb.append("SqlProvider"); //$NON-NLS-1$
- }
- setMyBatis3SqlProviderType(sb.toString());
- }
-}
diff --git a/src/main/java/tk/mybatis/mapper/generator/file/GenerateByListTemplateFile.java b/src/main/java/tk/mybatis/mapper/generator/file/GenerateByListTemplateFile.java
deleted file mode 100644
index df419706f..000000000
--- a/src/main/java/tk/mybatis/mapper/generator/file/GenerateByListTemplateFile.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * 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.file;
-
-import org.mybatis.generator.api.GeneratedJavaFile;
-import org.mybatis.generator.api.dom.java.CompilationUnit;
-import tk.mybatis.mapper.generator.formatter.ListTemplateFormatter;
-import tk.mybatis.mapper.generator.model.TableClass;
-
-import java.util.Properties;
-import java.util.Set;
-
-/**
- * @author liuzh
- * @since 3.4.5
- */
-public class GenerateByListTemplateFile extends GeneratedJavaFile {
- public static final String ENCODING = "UTF-8";
-
- private String targetPackage;
-
- private String fileNameTemplate;
-
- private String templateContent;
-
- private Properties properties;
-
- private Set tableClassSet;
-
- private ListTemplateFormatter templateFormatter;
-
- public GenerateByListTemplateFile(Set tableClassSet, ListTemplateFormatter templateFormatter, Properties properties, String targetProject, String targetPackage, String fileNameTemplate, String templateContent) {
- super(null, targetProject, ENCODING, null);
- this.targetProject = targetProject;
- this.targetPackage = targetPackage;
- this.fileNameTemplate = fileNameTemplate;
- this.templateContent = templateContent;
- this.properties = properties;
- this.tableClassSet = tableClassSet;
- this.templateFormatter = templateFormatter;
- }
-
- @Override
- public CompilationUnit getCompilationUnit() {
- return null;
- }
-
- @Override
- public String getFileName() {
- return templateFormatter.getFormattedContent(tableClassSet, properties, targetPackage, fileNameTemplate);
- }
-
- @Override
- public String getFormattedContent() {
- return templateFormatter.getFormattedContent(tableClassSet, properties, targetPackage, templateContent);
- }
-
- @Override
- public String getTargetPackage() {
- return targetPackage;
- }
-
- @Override
- public boolean isMergeable() {
- return false;
- }
-
-}
diff --git a/src/main/java/tk/mybatis/mapper/generator/file/GenerateByTemplateFile.java b/src/main/java/tk/mybatis/mapper/generator/file/GenerateByTemplateFile.java
deleted file mode 100644
index 0fa76950f..000000000
--- a/src/main/java/tk/mybatis/mapper/generator/file/GenerateByTemplateFile.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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.file;
-
-import org.mybatis.generator.api.GeneratedJavaFile;
-import org.mybatis.generator.api.dom.java.CompilationUnit;
-import tk.mybatis.mapper.generator.formatter.TemplateFormatter;
-import tk.mybatis.mapper.generator.model.TableClass;
-
-import java.util.Properties;
-
-/**
- * @author liuzh
- * @since 3.4.5
- */
-public class GenerateByTemplateFile extends GeneratedJavaFile {
- public static final String ENCODING = "UTF-8";
-
- private String targetPackage;
-
- private String fileName;
-
- private String templateContent;
-
- private Properties properties;
-
- private TableClass tableClass;
-
- private TemplateFormatter templateFormatter;
-
- public GenerateByTemplateFile(TableClass tableClass, TemplateFormatter templateFormatter, Properties properties, String targetProject, String targetPackage, String fileName, String templateContent) {
- super(null, targetProject, ENCODING, null);
- this.targetProject = targetProject;
- this.targetPackage = targetPackage;
- this.fileName = fileName;
- this.templateContent = templateContent;
- this.properties = properties;
- this.tableClass = tableClass;
- this.templateFormatter = templateFormatter;
- }
-
- @Override
- public CompilationUnit getCompilationUnit() {
- return null;
- }
-
- @Override
- public String getFileName() {
- return templateFormatter.getFormattedContent(tableClass, properties, targetPackage, fileName);
- }
-
- @Override
- public String getFormattedContent() {
- return templateFormatter.getFormattedContent(tableClass, properties, targetPackage, templateContent);
- }
-
- @Override
- public String getTargetPackage() {
- return templateFormatter.getFormattedContent(tableClass, properties, targetPackage, targetPackage);
- }
-
- @Override
- public boolean isMergeable() {
- return false;
- }
-
-}
diff --git a/src/main/java/tk/mybatis/mapper/generator/formatter/FreemarkerTemplateFormatter.java b/src/main/java/tk/mybatis/mapper/generator/formatter/FreemarkerTemplateFormatter.java
deleted file mode 100644
index cf96809d6..000000000
--- a/src/main/java/tk/mybatis/mapper/generator/formatter/FreemarkerTemplateFormatter.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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.formatter;
-
-
-import freemarker.cache.StringTemplateLoader;
-import freemarker.template.Configuration;
-import freemarker.template.DefaultObjectWrapper;
-import freemarker.template.Template;
-import tk.mybatis.mapper.generator.model.TableClass;
-
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.*;
-
-/**
- * 基于 freemarker 的实现
- *
- * @author liuzh
- * @since 3.4.5
- */
-public class FreemarkerTemplateFormatter implements TemplateFormatter, ListTemplateFormatter {
- private final Configuration configuration = new Configuration(Configuration.VERSION_2_3_23);
- private final StringTemplateLoader templateLoader = new StringTemplateLoader();
-
- public FreemarkerTemplateFormatter() {
- configuration.setLocale(Locale.CHINA);
- configuration.setDefaultEncoding("UTF-8");
- configuration.setTemplateLoader(templateLoader);
- configuration.setObjectWrapper(new DefaultObjectWrapper(Configuration.VERSION_2_3_23));
- }
-
- /**
- * 根据模板处理
- *
- * @param templateName
- * @param templateSource
- * @param params
- * @return
- */
- public String process(String templateName, String templateSource, Map params) {
- try {
- Template template = new Template(templateName, templateSource, configuration);
- Writer writer = new StringWriter();
- template.process(params, writer);
- return writer.toString();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- @Override
- public String getFormattedContent(TableClass tableClass, Properties properties, String targetPackage, String templateContent) {
- Map params = new HashMap();
- for (Object o : properties.keySet()) {
- params.put(String.valueOf(o), properties.get(o));
- }
- params.put("props", properties);
- params.put("package", targetPackage);
- params.put("tableClass", tableClass);
- return process(properties.getProperty("templatePath"), templateContent, params);
- }
-
- @Override
- public String getFormattedContent(Set tableClassSet, Properties properties, String targetPackage, String templateContent) {
- Map params = new HashMap();
- for (Object o : properties.keySet()) {
- params.put(String.valueOf(o), properties.get(o));
- }
- params.put("props", properties);
- params.put("package", targetPackage);
- params.put("tableClassSet", tableClassSet);
- return process(properties.getProperty("templatePath"), templateContent, params);
- }
-}
diff --git a/src/main/java/tk/mybatis/mapper/generator/formatter/ListTemplateFormatter.java b/src/main/java/tk/mybatis/mapper/generator/formatter/ListTemplateFormatter.java
deleted file mode 100644
index b78983d8c..000000000
--- a/src/main/java/tk/mybatis/mapper/generator/formatter/ListTemplateFormatter.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.formatter;
-
-import tk.mybatis.mapper.generator.model.TableClass;
-
-import java.util.Properties;
-import java.util.Set;
-
-/**
- * @author liuzh
- * @since 3.4.5
- */
-public interface ListTemplateFormatter {
-
- /**
- * 获取根据模板生成的数据
- *
- * @param tableClassSet
- * @param properties
- * @param targetPackage
- * @param templateContent
- * @return
- */
- String getFormattedContent(Set tableClassSet, Properties properties, String targetPackage, String templateContent);
-}
diff --git a/src/main/java/tk/mybatis/mapper/generator/formatter/TemplateFormatter.java b/src/main/java/tk/mybatis/mapper/generator/formatter/TemplateFormatter.java
deleted file mode 100644
index 7c0d6256e..000000000
--- a/src/main/java/tk/mybatis/mapper/generator/formatter/TemplateFormatter.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.formatter;
-
-import tk.mybatis.mapper.generator.model.TableClass;
-
-import java.util.Properties;
-
-/**
- * @author liuzh
- * @since 3.4.5
- */
-public interface TemplateFormatter {
-
- /**
- * 获取根据模板生成的数据
- *
- * @param tableClass
- * @param properties
- * @param targetPackage
- * @param templateContent
- * @return
- */
- String getFormattedContent(TableClass tableClass, Properties properties, String targetPackage, String templateContent);
-}
diff --git a/src/main/java/tk/mybatis/mapper/generator/model/ColumnField.java b/src/main/java/tk/mybatis/mapper/generator/model/ColumnField.java
deleted file mode 100644
index bda744062..000000000
--- a/src/main/java/tk/mybatis/mapper/generator/model/ColumnField.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * 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.model;
-
-import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
-
-import java.io.Serializable;
-
-/**
- * @author liuzh
- * @since 3.4.5
- */
-public class ColumnField implements Serializable {
-
- private static final long serialVersionUID = -435113788623615260L;
- private TableClass tableClass;
- private String columnName;
- private String jdbcType;
- private String fieldName;
- private String remarks;
- private FullyQualifiedJavaType type;
- private String typePackage;
- private String shortTypeName;
- private String fullTypeName;
- private boolean identity;
- private boolean nullable;
- private boolean blobColumn;
- private boolean stringColumn;
- private boolean jdbcCharacterColumn;
- private boolean jdbcDateColumn;
- private boolean jdbcTimeColumn;
- private boolean sequenceColumn;
- private int length;
- private int scale;
-
- public String getColumnName() {
- return columnName;
- }
-
- public void setColumnName(String columnName) {
- this.columnName = columnName;
- }
-
- public String getFieldName() {
- return fieldName;
- }
-
- public void setFieldName(String fieldName) {
- this.fieldName = fieldName;
- }
-
- public String getFullTypeName() {
- return fullTypeName;
- }
-
- public void setFullTypeName(String fullTypeName) {
- this.fullTypeName = fullTypeName;
- }
-
- public String getJdbcType() {
- return jdbcType;
- }
-
- public void setJdbcType(String jdbcType) {
- this.jdbcType = jdbcType;
- }
-
- public int getLength() {
- return length;
- }
-
- public void setLength(int length) {
- this.length = length;
- }
-
- public String getRemarks() {
- return remarks;
- }
-
- public void setRemarks(String remarks) {
- this.remarks = remarks;
- }
-
- public int getScale() {
- return scale;
- }
-
- public void setScale(int scale) {
- this.scale = scale;
- }
-
- public String getShortTypeName() {
- return shortTypeName;
- }
-
- public void setShortTypeName(String shortTypeName) {
- this.shortTypeName = shortTypeName;
- }
-
- public TableClass getTableClass() {
- return tableClass;
- }
-
- public void setTableClass(TableClass tableClass) {
- this.tableClass = tableClass;
- }
-
- public FullyQualifiedJavaType getType() {
- return type;
- }
-
- public void setType(FullyQualifiedJavaType type) {
- this.type = type;
- }
-
- public String getTypePackage() {
- return typePackage;
- }
-
- public void setTypePackage(String typePackage) {
- this.typePackage = typePackage;
- }
-
- public boolean isBlobColumn() {
- return blobColumn;
- }
-
- public void setBlobColumn(boolean blobColumn) {
- this.blobColumn = blobColumn;
- }
-
- public boolean isIdentity() {
- return identity;
- }
-
- public void setIdentity(boolean identity) {
- this.identity = identity;
- }
-
- public boolean isJdbcCharacterColumn() {
- return jdbcCharacterColumn;
- }
-
- public void setJdbcCharacterColumn(boolean jdbcCharacterColumn) {
- this.jdbcCharacterColumn = jdbcCharacterColumn;
- }
-
- public boolean isJdbcDateColumn() {
- return jdbcDateColumn;
- }
-
- public void setJdbcDateColumn(boolean jdbcDateColumn) {
- this.jdbcDateColumn = jdbcDateColumn;
- }
-
- public boolean isJdbcTimeColumn() {
- return jdbcTimeColumn;
- }
-
- public void setJdbcTimeColumn(boolean jdbcTimeColumn) {
- this.jdbcTimeColumn = jdbcTimeColumn;
- }
-
- public boolean isNullable() {
- return nullable;
- }
-
- public void setNullable(boolean nullable) {
- this.nullable = nullable;
- }
-
- public boolean isSequenceColumn() {
- return sequenceColumn;
- }
-
- public void setSequenceColumn(boolean sequenceColumn) {
- this.sequenceColumn = sequenceColumn;
- }
-
- public boolean isStringColumn() {
- return stringColumn;
- }
-
- public void setStringColumn(boolean stringColumn) {
- this.stringColumn = stringColumn;
- }
-}
diff --git a/src/main/java/tk/mybatis/mapper/generator/model/TableClass.java b/src/main/java/tk/mybatis/mapper/generator/model/TableClass.java
deleted file mode 100644
index 2668bc5d1..000000000
--- a/src/main/java/tk/mybatis/mapper/generator/model/TableClass.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * 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.model;
-
-import org.mybatis.generator.api.IntrospectedTable;
-import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
-
-import java.io.Serializable;
-import java.util.List;
-
-/**
- * @author liuzh
- * @since 3.4.5
- */
-public class TableClass implements Serializable {
- private static final long serialVersionUID = -746251813735169289L;
-
- private IntrospectedTable introspectedTable;
-
- private String tableName;
- private String variableName;
- private String lowerCaseName;
- private String shortClassName;
- private String fullClassName;
- private String packageName;
- private FullyQualifiedJavaType type;
-
- private List pkFields;
- private List baseFields;
- private List blobFields;
- private List allFields;
-
- public List getAllFields() {
- return allFields;
- }
-
- public void setAllFields(List allFields) {
- this.allFields = allFields;
- }
-
- public List getBaseFields() {
- return baseFields;
- }
-
- public void setBaseFields(List baseFields) {
- this.baseFields = baseFields;
- }
-
- public List getBlobFields() {
- return blobFields;
- }
-
- public void setBlobFields(List blobFields) {
- this.blobFields = blobFields;
- }
-
- public String getFullClassName() {
- return fullClassName;
- }
-
- public void setFullClassName(String fullClassName) {
- this.fullClassName = fullClassName;
- }
-
- public IntrospectedTable getIntrospectedTable() {
- return introspectedTable;
- }
-
- public void setIntrospectedTable(IntrospectedTable introspectedTable) {
- this.introspectedTable = introspectedTable;
- }
-
- public String getLowerCaseName() {
- return lowerCaseName;
- }
-
- public void setLowerCaseName(String lowerCaseName) {
- this.lowerCaseName = lowerCaseName;
- }
-
- public String getPackageName() {
- return packageName;
- }
-
- public void setPackageName(String packageName) {
- this.packageName = packageName;
- }
-
- public List getPkFields() {
- return pkFields;
- }
-
- public void setPkFields(List pkFields) {
- this.pkFields = pkFields;
- }
-
- public String getShortClassName() {
- return shortClassName;
- }
-
- public void setShortClassName(String shortClassName) {
- this.shortClassName = shortClassName;
- }
-
- public String getTableName() {
- return tableName;
- }
-
- public void setTableName(String tableName) {
- this.tableName = tableName;
- }
-
- public FullyQualifiedJavaType getType() {
- return type;
- }
-
- public void setType(FullyQualifiedJavaType type) {
- this.type = type;
- }
-
- public String getVariableName() {
- return variableName;
- }
-
- public void setVariableName(String variableName) {
- this.variableName = variableName;
- }
-}
diff --git a/src/main/java/tk/mybatis/mapper/generator/model/TableColumnBuilder.java b/src/main/java/tk/mybatis/mapper/generator/model/TableColumnBuilder.java
deleted file mode 100644
index 7c0ceca5f..000000000
--- a/src/main/java/tk/mybatis/mapper/generator/model/TableColumnBuilder.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * 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.model;
-
-import org.mybatis.generator.api.FullyQualifiedTable;
-import org.mybatis.generator.api.IntrospectedColumn;
-import org.mybatis.generator.api.IntrospectedTable;
-import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
-
-import java.beans.Introspector;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author liuzh
- * @since 3.4.5
- */
-public class TableColumnBuilder {
-
- /**
- * 创建 TableClass
- *
- * @param introspectedTable
- * @return
- */
- public static TableClass build(IntrospectedTable introspectedTable) {
- TableClass tableClass = new TableClass();
- tableClass.setIntrospectedTable(introspectedTable);
-
- FullyQualifiedTable fullyQualifiedTable = introspectedTable.getFullyQualifiedTable();
- tableClass.setTableName(fullyQualifiedTable.getIntrospectedTableName());
-
- FullyQualifiedJavaType type = new FullyQualifiedJavaType(introspectedTable.getBaseRecordType());
- tableClass.setType(type);
- tableClass.setVariableName(Introspector.decapitalize(type.getShortName()));
- tableClass.setLowerCaseName(type.getShortName().toLowerCase());
- tableClass.setShortClassName(type.getShortName());
- tableClass.setFullClassName(type.getFullyQualifiedName());
- tableClass.setPackageName(type.getPackageName());
-
- List pkFields = new ArrayList();
- List baseFields = new ArrayList();
- List blobFields = new ArrayList();
- List allFields = new ArrayList();
- for (IntrospectedColumn column : introspectedTable.getPrimaryKeyColumns()) {
- ColumnField field = build(column);
- field.setTableClass(tableClass);
- pkFields.add(field);
- allFields.add(field);
- }
- for (IntrospectedColumn column : introspectedTable.getBaseColumns()) {
- ColumnField field = build(column);
- field.setTableClass(tableClass);
- baseFields.add(field);
- allFields.add(field);
- }
- for (IntrospectedColumn column : introspectedTable.getBLOBColumns()) {
- ColumnField field = build(column);
- field.setTableClass(tableClass);
- blobFields.add(field);
- allFields.add(field);
- }
- tableClass.setPkFields(pkFields);
- tableClass.setBaseFields(baseFields);
- tableClass.setBlobFields(blobFields);
- tableClass.setAllFields(allFields);
-
- return tableClass;
- }
-
- /**
- * 创建 ColumnField
- *
- * @param column
- * @return
- */
- public static ColumnField build(IntrospectedColumn column) {
- ColumnField field = new ColumnField();
- field.setColumnName(column.getActualColumnName());
- field.setJdbcType(column.getJdbcTypeName());
- field.setFieldName(column.getJavaProperty());
- field.setRemarks(column.getRemarks());
- FullyQualifiedJavaType type = column.getFullyQualifiedJavaType();
- field.setType(type);
- field.setTypePackage(type.getPackageName());
- field.setShortTypeName(type.getShortName());
- field.setFullTypeName(type.getFullyQualifiedName());
- field.setIdentity(column.isIdentity());
- field.setNullable(column.isNullable());
- field.setSequenceColumn(column.isSequenceColumn());
- field.setBlobColumn(column.isBLOBColumn());
- field.setStringColumn(column.isStringColumn());
- field.setJdbcCharacterColumn(column.isJdbcCharacterColumn());
- field.setJdbcDateColumn(column.isJDBCDateColumn());
- field.setJdbcTimeColumn(column.isJDBCTimeColumn());
- field.setLength(column.getLength());
- field.setScale(column.getScale());
- return field;
- }
-
-
-}
diff --git a/src/main/java/tk/mybatis/spring/mapper/MapperFactoryBean.java b/src/main/java/tk/mybatis/spring/mapper/MapperFactoryBean.java
deleted file mode 100644
index 2fddffa58..000000000
--- a/src/main/java/tk/mybatis/spring/mapper/MapperFactoryBean.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.spring.mapper;
-
-import tk.mybatis.mapper.mapperhelper.MapperHelper;
-
-/**
- * 增加mapperHelper
- *
- * @param
- * @author liuzh
- */
-public class MapperFactoryBean extends org.mybatis.spring.mapper.MapperFactoryBean {
-
- private MapperHelper mapperHelper;
-
- public MapperFactoryBean() {
- }
-
- public MapperFactoryBean(Class mapperInterface) {
- super(mapperInterface);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void checkDaoConfig() {
- super.checkDaoConfig();
- //通用Mapper
- if (mapperHelper.isExtendCommonMapper(getObjectType())) {
- mapperHelper.processConfiguration(getSqlSession().getConfiguration(), getObjectType());
- }
- }
-
- public void setMapperHelper(MapperHelper mapperHelper) {
- this.mapperHelper = mapperHelper;
- }
-}
diff --git a/src/main/java/tk/mybatis/spring/mapper/MapperScannerConfigurer.java b/src/main/java/tk/mybatis/spring/mapper/MapperScannerConfigurer.java
deleted file mode 100644
index 3049d2c4f..000000000
--- a/src/main/java/tk/mybatis/spring/mapper/MapperScannerConfigurer.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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.spring.mapper;
-
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-import org.springframework.beans.factory.support.GenericBeanDefinition;
-import tk.mybatis.mapper.common.Marker;
-import tk.mybatis.mapper.mapperhelper.MapperHelper;
-import tk.mybatis.mapper.util.StringUtil;
-
-import java.util.Properties;
-
-
-public class MapperScannerConfigurer extends org.mybatis.spring.mapper.MapperScannerConfigurer {
- private MapperHelper mapperHelper = new MapperHelper();
-
- /**
- * 注册完成后,对MapperFactoryBean的类进行特殊处理
- *
- * @param registry
- */
- @Override
- public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) {
- super.postProcessBeanDefinitionRegistry(registry);
- //如果没有注册过接口,就注册默认的Mapper接口
- this.mapperHelper.ifEmptyRegisterDefaultInterface();
- String[] names = registry.getBeanDefinitionNames();
- GenericBeanDefinition definition;
- for (String name : names) {
- BeanDefinition beanDefinition = registry.getBeanDefinition(name);
- if (beanDefinition instanceof GenericBeanDefinition) {
- definition = (GenericBeanDefinition) beanDefinition;
- if (StringUtil.isNotEmpty(definition.getBeanClassName())
- && definition.getBeanClassName().equals("org.mybatis.spring.mapper.MapperFactoryBean")) {
- definition.setBeanClass(MapperFactoryBean.class);
- definition.getPropertyValues().add("mapperHelper", this.mapperHelper);
- }
- }
- }
- }
-
- 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
deleted file mode 100644
index 614902fe3..000000000
--- a/src/main/resources/META-INF/spring-devtools.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# 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/generator/Generator.java b/src/test/java/tk/mybatis/mapper/generator/Generator.java
deleted file mode 100644
index 549a20560..000000000
--- a/src/test/java/tk/mybatis/mapper/generator/Generator.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.api.MyBatisGenerator;
-import org.mybatis.generator.config.Configuration;
-import org.mybatis.generator.config.xml.ConfigurationParser;
-import org.mybatis.generator.internal.DefaultShellCallback;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author liuzh
- */
-public class Generator {
- public static void main(String[] args) throws Exception {
- List warnings = new ArrayList();
- boolean overwrite = true;
- ConfigurationParser cp = new ConfigurationParser(warnings);
- Configuration config = cp.parseConfiguration(
- Generator.class.getResourceAsStream("/generator/generatorConfig.xml"));
- DefaultShellCallback callback = new DefaultShellCallback(overwrite);
- MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
- myBatisGenerator.generate(null);
- }
-}
From cd37879c7bd89c6b433d2db01053bdafede56b9d Mon Sep 17 00:00:00 2001
From: isea533
Date: Tue, 30 Jan 2018 21:11:52 +0800
Subject: [PATCH 109/407] =?UTF-8?q?=E5=8E=BB=E6=8E=89=20generator=20?=
=?UTF-8?q?=E7=9B=B8=E5=85=B3=E5=86=85=E5=AE=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/resources/generator/mapper.ftl | 16 ---
src/main/resources/generator/mapperXml.ftl | 7 --
src/main/resources/generator/test-all.ftl | 106 ------------------
src/main/resources/generator/test-one.ftl | 103 -----------------
.../resources/generator/generatorConfig.xml | 94 ----------------
5 files changed, 326 deletions(-)
delete mode 100644 src/main/resources/generator/mapper.ftl
delete mode 100644 src/main/resources/generator/mapperXml.ftl
delete mode 100644 src/main/resources/generator/test-all.ftl
delete mode 100644 src/main/resources/generator/test-one.ftl
delete mode 100644 src/test/resources/generator/generatorConfig.xml
diff --git a/src/main/resources/generator/mapper.ftl b/src/main/resources/generator/mapper.ftl
deleted file mode 100644
index 49e0bb20f..000000000
--- a/src/main/resources/generator/mapper.ftl
+++ /dev/null
@@ -1,16 +0,0 @@
-package ${package};
-
-import ${tableClass.fullClassName};
-
-/**
-* 通用 Mapper 代码生成器
-*
-* @author mapper-generator
-*/
-public interface ${tableClass.shortClassName}${mapperSuffix} extends ${baseMapper!"tk.mybatis.mapper.common.Mapper"}<${tableClass.shortClassName}> {
-
-}
-
-
-
-
diff --git a/src/main/resources/generator/mapperXml.ftl b/src/main/resources/generator/mapperXml.ftl
deleted file mode 100644
index 9c3994c24..000000000
--- a/src/main/resources/generator/mapperXml.ftl
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
diff --git a/src/main/resources/generator/test-all.ftl b/src/main/resources/generator/test-all.ftl
deleted file mode 100644
index 3104b3978..000000000
--- a/src/main/resources/generator/test-all.ftl
+++ /dev/null
@@ -1,106 +0,0 @@
-目标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>
-
-<#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
deleted file mode 100644
index 2de6fe68d..000000000
--- a/src/main/resources/generator/test-one.ftl
+++ /dev/null
@@ -1,103 +0,0 @@
-目标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
deleted file mode 100644
index 1fb1aa757..000000000
--- a/src/test/resources/generator/generatorConfig.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ * 不支持主键策略,插入前需要设置好主键的值
+ *
+ * @param recordList
+ * @return
+ */
+ @InsertProvider(type = InsertListProvider.class, method = "dynamicSQL")
+ int insertList(List recordList);
+}
\ No newline at end of file
diff --git a/extra/src/main/java/tk/mybatis/mapper/additional/insert/InsertListProvider.java b/extra/src/main/java/tk/mybatis/mapper/additional/insert/InsertListProvider.java
new file mode 100644
index 000000000..5204d4134
--- /dev/null
+++ b/extra/src/main/java/tk/mybatis/mapper/additional/insert/InsertListProvider.java
@@ -0,0 +1,72 @@
+/*
+ * 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.additional.insert;
+
+import org.apache.ibatis.mapping.MappedStatement;
+import tk.mybatis.mapper.entity.EntityColumn;
+import tk.mybatis.mapper.mapperhelper.EntityHelper;
+import tk.mybatis.mapper.mapperhelper.MapperHelper;
+import tk.mybatis.mapper.mapperhelper.MapperTemplate;
+import tk.mybatis.mapper.mapperhelper.SqlHelper;
+
+import java.util.Set;
+
+/**
+ * @author liuzh
+ */
+public class InsertListProvider extends MapperTemplate {
+
+ public InsertListProvider(Class> mapperClass, MapperHelper mapperHelper) {
+ super(mapperClass, mapperHelper);
+ }
+
+ /**
+ * 批量插入
+ *
+ * @param ms
+ */
+ public String insertList(MappedStatement ms) {
+ final Class> entityClass = getEntityClass(ms);
+ //开始拼sql
+ StringBuilder sql = new StringBuilder();
+ sql.append(SqlHelper.insertIntoTable(entityClass, tableName(entityClass)));
+ sql.append(SqlHelper.insertColumns(entityClass, false, false, false));
+ sql.append(" VALUES ");
+ sql.append("");
+ sql.append("");
+ //获取全部列
+ Set columnList = EntityHelper.getColumns(entityClass);
+ //当某个列有主键策略时,不需要考虑他的属性是否为空,因为如果为空,一定会根据主键策略给他生成一个值
+ for (EntityColumn column : columnList) {
+ if (column.isInsertable()) {
+ sql.append(column.getColumnHolder("record") + ",");
+ }
+ }
+ sql.append("");
+ sql.append("");
+ return sql.toString();
+ }
+
+}
diff --git a/generator/README.md b/generator/README.md
new file mode 100644
index 000000000..5391b1d27
--- /dev/null
+++ b/generator/README.md
@@ -0,0 +1,614 @@
+# Mybatis 通用 Mapper 代码生成器
+
+[](https://maven-badges.herokuapp.com/maven-central/tk.mybatis/mapper-generator)
+
+整个插件只有很少代码是和通用 Mapper 相关的,并且也没有直接的依赖关系。
+
+这个代码生成器实际上是对 MyBatis Generator 的一个扩展,使用这个扩展可以很方便的使用 Freemarker 模板语言编写代码。
+
+## 测试
+
+在 src/test/java 下面,`tk.mybatis.mapper.generator` 包下面有一个测试类 `Generator`。
+
+可以直接运行这个测试类查看生成代码的效果。所有生成的代码在 `src/test/java/test` 目录下,方便删除。
+
+测试使用的 hsqldb 内存数据库,数据库建表 SQL 在 src/test/resources 下面的 `CreateDB.sql` 中。
+
+代码生成器的配置在 `generatorConfig.xml` 中。
+
+
+# 代码生成器文档
+
+代码生成器是基于 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` 生成包(本质上还是目录)。
+
+这个属性还有一个特殊的地方,它还支持使用模板,就和下面的 `fileName` 一样,举个简单的使用场景。
+
+>你可能在生成前端代码的时候,希望将表对应的 JSP 生成在自己的一个目录中,此时可以配置为:
+>
+>``
+>
+>模板中可以用到的属性,这里都能用,其他属性后面会介绍。
+
+通过这个路径也能看出来,配置一个插件只能根据模板在一个指定位置(targetProject 和 targetPackage 决定的目录)生成一个文件。
+
+### 3. `templatePath`
+
+指定模板路径,可以是任意能够通过 ClassLoader 能够获取的位置,文件类型没有限制。
+
+例如示例中的 `generator/test-one.ftl`。
+
+**这个属性必须指定,否则不会生成代码!**
+
+### 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 改版后,捐赠列表好久都没更新过了,如果你觉得这个插件和本文有用,可以小小的捐赠一笔。
+>
+>支付宝:
+>
+>
+>
+>微信:
+>
+>
diff --git a/generator/pom.xml b/generator/pom.xml
new file mode 100644
index 000000000..1a835a812
--- /dev/null
+++ b/generator/pom.xml
@@ -0,0 +1,65 @@
+
+
+
+ 4.0.0
+
+ tk.mybatis
+ mapper-parent
+ 1
+
+ mapper-generator
+ 1.0.0-SNAPSHOT
+ jar
+
+ mapper-generator
+ Mybatis 通用 Mapper 代码生成器
+
+
+ 2.3.23
+ 1.3.6
+
+
+
+
+ org.freemarker
+ freemarker
+ ${freemarker.version}
+ provided
+
+
+ org.mybatis.generator
+ mybatis-generator-core
+ ${generator.version}
+ provided
+
+
+ org.hsqldb
+ sqltool
+ 2.3.3
+ test
+
+
+
diff --git a/generator/src/main/java/tk/mybatis/mapper/generator/FalseMethodPlugin.java b/generator/src/main/java/tk/mybatis/mapper/generator/FalseMethodPlugin.java
new file mode 100644
index 000000000..ceea47bfb
--- /dev/null
+++ b/generator/src/main/java/tk/mybatis/mapper/generator/FalseMethodPlugin.java
@@ -0,0 +1,189 @@
+/*
+ * 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.api.IntrospectedTable;
+import org.mybatis.generator.api.PluginAdapter;
+import org.mybatis.generator.api.dom.java.Interface;
+import org.mybatis.generator.api.dom.java.Method;
+import org.mybatis.generator.api.dom.java.TopLevelClass;
+import org.mybatis.generator.api.dom.xml.XmlElement;
+
+import java.util.List;
+
+/**
+ * 禁用大多数方法
+ *
+ * @author liuzh
+ */
+public class FalseMethodPlugin extends PluginAdapter {
+
+ @Override
+ public boolean validate(List warnings) {
+ return true;
+ }
+
+ //下面所有return false的方法都不生成。这些都是基础的CRUD方法,使用通用Mapper实现
+ @Override
+ public boolean clientDeleteByPrimaryKeyMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+ @Override
+ public boolean clientInsertMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+ @Override
+ public boolean clientInsertSelectiveMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+ @Override
+ public boolean clientSelectByPrimaryKeyMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+ @Override
+ public boolean clientUpdateByPrimaryKeySelectiveMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+ @Override
+ public boolean clientUpdateByPrimaryKeyWithBLOBsMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+ @Override
+ public boolean clientUpdateByPrimaryKeyWithoutBLOBsMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+ @Override
+ public boolean clientDeleteByPrimaryKeyMethodGenerated(Method method, Interface interfaze, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+ @Override
+ public boolean clientInsertMethodGenerated(Method method, Interface interfaze, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+ @Override
+ public boolean clientInsertSelectiveMethodGenerated(Method method, Interface interfaze, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+ @Override
+ public boolean clientSelectAllMethodGenerated(Method method, Interface interfaze, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+ @Override
+ public boolean clientSelectAllMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+ @Override
+ public boolean clientSelectByPrimaryKeyMethodGenerated(Method method, Interface interfaze, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+ @Override
+ public boolean clientUpdateByPrimaryKeySelectiveMethodGenerated(Method method, Interface interfaze, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+ @Override
+ public boolean clientUpdateByPrimaryKeyWithBLOBsMethodGenerated(Method method, Interface interfaze, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+ @Override
+ public boolean clientUpdateByPrimaryKeyWithoutBLOBsMethodGenerated(Method method, Interface interfaze, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+ @Override
+ public boolean sqlMapDeleteByPrimaryKeyElementGenerated(XmlElement element, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+ @Override
+ public boolean sqlMapInsertElementGenerated(XmlElement element, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+ @Override
+ public boolean sqlMapInsertSelectiveElementGenerated(XmlElement element, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+ @Override
+ public boolean sqlMapSelectAllElementGenerated(XmlElement element, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+ @Override
+ public boolean sqlMapSelectByPrimaryKeyElementGenerated(XmlElement element, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+ @Override
+ public boolean sqlMapUpdateByPrimaryKeySelectiveElementGenerated(XmlElement element, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+ @Override
+ public boolean sqlMapUpdateByPrimaryKeyWithBLOBsElementGenerated(XmlElement element, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+ @Override
+ public boolean sqlMapUpdateByPrimaryKeyWithoutBLOBsElementGenerated(XmlElement element, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+ @Override
+ public boolean providerGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+ @Override
+ public boolean providerApplyWhereMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+ @Override
+ public boolean providerInsertSelectiveMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+ @Override
+ public boolean providerUpdateByPrimaryKeySelectiveMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
+ return false;
+ }
+
+}
diff --git a/generator/src/main/java/tk/mybatis/mapper/generator/MapperCommentGenerator.java b/generator/src/main/java/tk/mybatis/mapper/generator/MapperCommentGenerator.java
new file mode 100644
index 000000000..638d3bf13
--- /dev/null
+++ b/generator/src/main/java/tk/mybatis/mapper/generator/MapperCommentGenerator.java
@@ -0,0 +1,317 @@
+/*
+ * 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.api.CommentGenerator;
+import org.mybatis.generator.api.IntrospectedColumn;
+import org.mybatis.generator.api.IntrospectedTable;
+import org.mybatis.generator.api.dom.java.*;
+import org.mybatis.generator.api.dom.xml.TextElement;
+import org.mybatis.generator.api.dom.xml.XmlElement;
+import org.mybatis.generator.config.MergeConstants;
+import org.mybatis.generator.internal.util.StringUtility;
+
+import java.text.MessageFormat;
+import java.util.Properties;
+import java.util.Set;
+
+public class MapperCommentGenerator implements CommentGenerator {
+ //开始的分隔符,例如mysql为`,sqlserver为[
+ private String beginningDelimiter = "";
+ //结束的分隔符,例如mysql为`,sqlserver为]
+ private String endingDelimiter = "";
+ //强制生成注解
+ private boolean forceAnnotation;
+
+ public MapperCommentGenerator() {
+ super();
+ }
+
+ @Override
+ public void addJavaFileComment(CompilationUnit compilationUnit) {
+ return;
+ }
+
+ /**
+ * xml中的注释
+ *
+ * @param xmlElement
+ */
+ @Override
+ public void addComment(XmlElement xmlElement) {
+ xmlElement.addElement(new TextElement(""));
+ }
+
+ @Override
+ public void addRootComment(XmlElement rootElement) {
+ return;
+ }
+
+ @Override
+ public void addConfigurationProperties(Properties properties) {
+ String beginningDelimiter = properties.getProperty("beginningDelimiter");
+ if (StringUtility.stringHasValue(beginningDelimiter)) {
+ this.beginningDelimiter = beginningDelimiter;
+ }
+ String endingDelimiter = properties.getProperty("endingDelimiter");
+ if (StringUtility.stringHasValue(endingDelimiter)) {
+ this.endingDelimiter = endingDelimiter;
+ }
+ String forceAnnotation = properties.getProperty("forceAnnotation");
+ if (StringUtility.stringHasValue(forceAnnotation)) {
+ this.forceAnnotation = forceAnnotation.equalsIgnoreCase("TRUE");
+ }
+ }
+
+ public String getDelimiterName(String name) {
+ StringBuilder nameBuilder = new StringBuilder();
+ nameBuilder.append(beginningDelimiter);
+ nameBuilder.append(name);
+ nameBuilder.append(endingDelimiter);
+ return nameBuilder.toString();
+ }
+
+ /**
+ * 删除标记
+ *
+ * @param javaElement
+ * @param markAsDoNotDelete
+ */
+ protected void addJavadocTag(JavaElement javaElement, boolean markAsDoNotDelete) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(" * ");
+ sb.append(MergeConstants.NEW_ELEMENT_TAG);
+ if (markAsDoNotDelete) {
+ sb.append(" do_not_delete_during_merge");
+ }
+ javaElement.addJavaDocLine(sb.toString());
+ }
+
+ /**
+ * Example使用
+ *
+ * @param innerClass
+ * @param introspectedTable
+ */
+ @Override
+ public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable) {
+ }
+
+ @Override
+ public void addEnumComment(InnerEnum innerEnum, IntrospectedTable introspectedTable) {
+ }
+
+ /**
+ * 给字段添加数据库备注
+ *
+ * @param field
+ * @param introspectedTable
+ * @param introspectedColumn
+ */
+ @Override
+ public void addFieldComment(Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
+ if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
+ field.addJavaDocLine("/**");
+ StringBuilder sb = new StringBuilder();
+ sb.append(" * ");
+ sb.append(introspectedColumn.getRemarks());
+ field.addJavaDocLine(sb.toString());
+ field.addJavaDocLine(" */");
+ }
+ //添加注解
+ if (field.isTransient()) {
+ //@Column
+ field.addAnnotation("@Transient");
+ }
+ for (IntrospectedColumn column : introspectedTable.getPrimaryKeyColumns()) {
+ if (introspectedColumn == column) {
+ field.addAnnotation("@Id");
+ break;
+ }
+ }
+ String column = introspectedColumn.getActualColumnName();
+ if (StringUtility.stringContainsSpace(column) || introspectedTable.getTableConfiguration().isAllColumnDelimitingEnabled()) {
+ column = introspectedColumn.getContext().getBeginningDelimiter()
+ + column
+ + introspectedColumn.getContext().getEndingDelimiter();
+ }
+ if (!column.equals(introspectedColumn.getJavaProperty())) {
+ //@Column
+ field.addAnnotation("@Column(name = \"" + getDelimiterName(column) + "\")");
+ } else if (StringUtility.stringHasValue(beginningDelimiter) || StringUtility.stringHasValue(endingDelimiter)) {
+ field.addAnnotation("@Column(name = \"" + getDelimiterName(column) + "\")");
+ } else if (forceAnnotation) {
+ field.addAnnotation("@Column(name = \"" + getDelimiterName(column) + "\")");
+ }
+ if (introspectedColumn.isIdentity()) {
+ if (introspectedTable.getTableConfiguration().getGeneratedKey().getRuntimeSqlStatement().equals("JDBC")) {
+ field.addAnnotation("@GeneratedValue(generator = \"JDBC\")");
+ } else {
+ field.addAnnotation("@GeneratedValue(strategy = GenerationType.IDENTITY)");
+ }
+ } else if (introspectedColumn.isSequenceColumn()) {
+ //在 Oracle 中,如果需要是 SEQ_TABLENAME,那么可以配置为 select SEQ_{1} from dual
+ String tableName = introspectedTable.getFullyQualifiedTableNameAtRuntime();
+ String sql = MessageFormat.format(introspectedTable.getTableConfiguration().getGeneratedKey().getRuntimeSqlStatement(), tableName, tableName.toUpperCase());
+ field.addAnnotation("@GeneratedValue(strategy = GenerationType.IDENTITY, generator = \"" + sql + "\")");
+ }
+ }
+
+ /**
+ * Example使用
+ *
+ * @param field
+ * @param introspectedTable
+ */
+ @Override
+ public void addFieldComment(Field field, IntrospectedTable introspectedTable) {
+ }
+
+ @Override
+ public void addModelClassComment(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
+
+ }
+
+ /**
+ * @param method
+ * @param introspectedTable
+ */
+ @Override
+ public void addGeneralMethodComment(Method method, IntrospectedTable introspectedTable) {
+ }
+
+ /**
+ * getter方法注释
+ *
+ * @param method
+ * @param introspectedTable
+ * @param introspectedColumn
+ */
+ @Override
+ public void addGetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
+ StringBuilder sb = new StringBuilder();
+ method.addJavaDocLine("/**");
+ if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
+ sb.append(" * 获取");
+ sb.append(introspectedColumn.getRemarks());
+ method.addJavaDocLine(sb.toString());
+ method.addJavaDocLine(" *");
+ }
+ sb.setLength(0);
+ sb.append(" * @return ");
+ sb.append(introspectedColumn.getActualColumnName());
+ if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
+ sb.append(" - ");
+ sb.append(introspectedColumn.getRemarks());
+ }
+ method.addJavaDocLine(sb.toString());
+ method.addJavaDocLine(" */");
+ }
+
+ /**
+ * setter方法注释
+ *
+ * @param method
+ * @param introspectedTable
+ * @param introspectedColumn
+ */
+ @Override
+ public void addSetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
+ StringBuilder sb = new StringBuilder();
+ method.addJavaDocLine("/**");
+ if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
+ sb.append(" * 设置");
+ sb.append(introspectedColumn.getRemarks());
+ method.addJavaDocLine(sb.toString());
+ method.addJavaDocLine(" *");
+ }
+ Parameter parm = method.getParameters().get(0);
+ sb.setLength(0);
+ sb.append(" * @param ");
+ sb.append(parm.getName());
+ if (StringUtility.stringHasValue(introspectedColumn.getRemarks())) {
+ sb.append(" ");
+ sb.append(introspectedColumn.getRemarks());
+ }
+ method.addJavaDocLine(sb.toString());
+ method.addJavaDocLine(" */");
+ }
+
+ /**
+ * Example使用
+ *
+ * @param innerClass
+ * @param introspectedTable
+ * @param markAsDoNotDelete
+ */
+ @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/generator/src/main/java/tk/mybatis/mapper/generator/MapperPlugin.java b/generator/src/main/java/tk/mybatis/mapper/generator/MapperPlugin.java
new file mode 100644
index 000000000..6cbfcd831
--- /dev/null
+++ b/generator/src/main/java/tk/mybatis/mapper/generator/MapperPlugin.java
@@ -0,0 +1,216 @@
+/*
+ * 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.api.IntrospectedTable;
+import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
+import org.mybatis.generator.api.dom.java.Interface;
+import org.mybatis.generator.api.dom.java.TopLevelClass;
+import org.mybatis.generator.config.CommentGeneratorConfiguration;
+import org.mybatis.generator.config.Context;
+import org.mybatis.generator.internal.util.StringUtility;
+
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+
+/**
+ * 通用Mapper生成器插件
+ *
+ * @author liuzh
+ */
+public class MapperPlugin extends FalseMethodPlugin {
+ private Set mappers = new HashSet();
+ private boolean caseSensitive = false;
+ private boolean useMapperCommentGenerator = true;
+ //开始的分隔符,例如mysql为`,sqlserver为[
+ private String beginningDelimiter = "";
+ //结束的分隔符,例如mysql为`,sqlserver为]
+ private String endingDelimiter = "";
+ //数据库模式
+ private String schema;
+ //注释生成器
+ private CommentGeneratorConfiguration commentCfg;
+ //强制生成注解
+ private boolean forceAnnotation;
+
+ public String getDelimiterName(String name) {
+ StringBuilder nameBuilder = new StringBuilder();
+ if (StringUtility.stringHasValue(schema)) {
+ nameBuilder.append(schema);
+ nameBuilder.append(".");
+ }
+ nameBuilder.append(beginningDelimiter);
+ nameBuilder.append(name);
+ nameBuilder.append(endingDelimiter);
+ return nameBuilder.toString();
+ }
+
+ /**
+ * 生成的Mapper接口
+ *
+ * @param interfaze
+ * @param topLevelClass
+ * @param introspectedTable
+ * @return
+ */
+ @Override
+ public boolean clientGenerated(Interface interfaze, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
+ //获取实体类
+ FullyQualifiedJavaType entityType = new FullyQualifiedJavaType(introspectedTable.getBaseRecordType());
+ //import接口
+ for (String mapper : mappers) {
+ interfaze.addImportedType(new FullyQualifiedJavaType(mapper));
+ interfaze.addSuperInterface(new FullyQualifiedJavaType(mapper + "<" + entityType.getShortName() + ">"));
+ }
+ //import实体类
+ interfaze.addImportedType(entityType);
+ return true;
+ }
+
+ /**
+ * 处理实体类的包和@Table注解
+ *
+ * @param topLevelClass
+ * @param introspectedTable
+ */
+ private void processEntityClass(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
+ //引入JPA注解
+ topLevelClass.addImportedType("javax.persistence.*");
+ String tableName = introspectedTable.getFullyQualifiedTableNameAtRuntime();
+ //如果包含空格,或者需要分隔符,需要完善
+ if (StringUtility.stringContainsSpace(tableName)) {
+ tableName = context.getBeginningDelimiter()
+ + tableName
+ + context.getEndingDelimiter();
+ }
+ //是否忽略大小写,对于区分大小写的数据库,会有用
+ if (caseSensitive && !topLevelClass.getType().getShortName().equals(tableName)) {
+ topLevelClass.addAnnotation("@Table(name = \"" + getDelimiterName(tableName) + "\")");
+ } else if (!topLevelClass.getType().getShortName().equalsIgnoreCase(tableName)) {
+ topLevelClass.addAnnotation("@Table(name = \"" + getDelimiterName(tableName) + "\")");
+ } else if (StringUtility.stringHasValue(schema)
+ || StringUtility.stringHasValue(beginningDelimiter)
+ || StringUtility.stringHasValue(endingDelimiter)) {
+ topLevelClass.addAnnotation("@Table(name = \"" + getDelimiterName(tableName) + "\")");
+ } else if (forceAnnotation) {
+ topLevelClass.addAnnotation("@Table(name = \"" + getDelimiterName(tableName) + "\")");
+ }
+ }
+
+ /**
+ * 生成基础实体类
+ *
+ * @param topLevelClass
+ * @param introspectedTable
+ * @return
+ */
+ @Override
+ public boolean modelBaseRecordClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
+ processEntityClass(topLevelClass, introspectedTable);
+ return true;
+ }
+
+ /**
+ * 生成实体类注解KEY对象
+ *
+ * @param topLevelClass
+ * @param introspectedTable
+ * @return
+ */
+ @Override
+ public boolean modelPrimaryKeyClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
+ processEntityClass(topLevelClass, introspectedTable);
+ return true;
+ }
+
+ /**
+ * 生成带BLOB字段的对象
+ *
+ * @param topLevelClass
+ * @param introspectedTable
+ * @return
+ */
+ @Override
+ public boolean modelRecordWithBLOBsClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
+ processEntityClass(topLevelClass, introspectedTable);
+ return false;
+ }
+
+
+ @Override
+ public void setContext(Context context) {
+ super.setContext(context);
+ //设置默认的注释生成器
+ useMapperCommentGenerator = !"FALSE".equalsIgnoreCase(context.getProperty("useMapperCommentGenerator"));
+ if (useMapperCommentGenerator) {
+ commentCfg = new CommentGeneratorConfiguration();
+ commentCfg.setConfigurationType(MapperCommentGenerator.class.getCanonicalName());
+ context.setCommentGeneratorConfiguration(commentCfg);
+ }
+ //支持oracle获取注释#114
+ context.getJdbcConnectionConfiguration().addProperty("remarksReporting", "true");
+ }
+
+ @Override
+ public void setProperties(Properties properties) {
+ super.setProperties(properties);
+ String mappers = this.properties.getProperty("mappers");
+ if (StringUtility.stringHasValue(mappers)) {
+ for (String mapper : mappers.split(",")) {
+ this.mappers.add(mapper);
+ }
+ } else {
+ throw new RuntimeException("Mapper插件缺少必要的mappers属性!");
+ }
+ String caseSensitive = this.properties.getProperty("caseSensitive");
+ if (StringUtility.stringHasValue(caseSensitive)) {
+ this.caseSensitive = caseSensitive.equalsIgnoreCase("TRUE");
+ }
+ String forceAnnotation = this.properties.getProperty("forceAnnotation");
+ if (StringUtility.stringHasValue(forceAnnotation)) {
+ if (useMapperCommentGenerator) {
+ commentCfg.addProperty("forceAnnotation", forceAnnotation);
+ }
+ this.forceAnnotation = forceAnnotation.equalsIgnoreCase("TRUE");
+ }
+ String beginningDelimiter = this.properties.getProperty("beginningDelimiter");
+ if (StringUtility.stringHasValue(beginningDelimiter)) {
+ this.beginningDelimiter = beginningDelimiter;
+ }
+ String endingDelimiter = this.properties.getProperty("endingDelimiter");
+ if (StringUtility.stringHasValue(endingDelimiter)) {
+ this.endingDelimiter = endingDelimiter;
+ }
+ String schema = this.properties.getProperty("schema");
+ if (StringUtility.stringHasValue(schema)) {
+ this.schema = schema;
+ }
+ if (useMapperCommentGenerator) {
+ commentCfg.addProperty("beginningDelimiter", this.beginningDelimiter);
+ commentCfg.addProperty("endingDelimiter", this.endingDelimiter);
+ }
+ }
+}
diff --git a/generator/src/main/java/tk/mybatis/mapper/generator/TemplateFilePlugin.java b/generator/src/main/java/tk/mybatis/mapper/generator/TemplateFilePlugin.java
new file mode 100644
index 000000000..183268e44
--- /dev/null
+++ b/generator/src/main/java/tk/mybatis/mapper/generator/TemplateFilePlugin.java
@@ -0,0 +1,229 @@
+/*
+ * 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.api.GeneratedJavaFile;
+import org.mybatis.generator.api.IntrospectedColumn;
+import org.mybatis.generator.api.IntrospectedTable;
+import org.mybatis.generator.api.PluginAdapter;
+import org.mybatis.generator.api.dom.java.Field;
+import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
+import org.mybatis.generator.api.dom.java.JavaVisibility;
+import org.mybatis.generator.internal.ObjectFactory;
+import org.mybatis.generator.internal.util.StringUtility;
+import tk.mybatis.mapper.generator.file.GenerateByListTemplateFile;
+import tk.mybatis.mapper.generator.file.GenerateByTemplateFile;
+import tk.mybatis.mapper.generator.formatter.ListTemplateFormatter;
+import tk.mybatis.mapper.generator.formatter.TemplateFormatter;
+import tk.mybatis.mapper.generator.model.TableClass;
+import tk.mybatis.mapper.generator.model.TableColumnBuilder;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.*;
+
+/**
+ * 每一个模板都需要配置一个插件,可以配置多个
+ *
+ *
+ * @author liuzh
+ * @since 2016-09-04 09:57
+ */
+public class TkMyBatis3Impl extends IntrospectedTableMyBatis3Impl {
+
+ @Override
+ protected String calculateMyBatis3XmlMapperFileName() {
+ StringBuilder sb = new StringBuilder();
+ if (stringHasValue(tableConfiguration.getMapperName())) {
+ String mapperName = tableConfiguration.getMapperName();
+ int ind = mapperName.lastIndexOf('.');
+ if (ind != -1) {
+ mapperName = mapperName.substring(ind + 1);
+ }
+ //支持mapperName = "{0}Dao" 等用法
+ sb.append(MessageFormat.format(mapperName, fullyQualifiedTable.getDomainObjectName()));
+ sb.append(".xml"); //$NON-NLS-1$
+ } else {
+ sb.append(fullyQualifiedTable.getDomainObjectName());
+ sb.append("Mapper.xml"); //$NON-NLS-1$
+ }
+ return sb.toString();
+ }
+
+ @Override
+ protected void calculateJavaClientAttributes() {
+ if (context.getJavaClientGeneratorConfiguration() == null) {
+ return;
+ }
+
+ StringBuilder sb = new StringBuilder();
+ sb.append(calculateJavaClientImplementationPackage());
+ sb.append('.');
+ sb.append(fullyQualifiedTable.getDomainObjectName());
+ sb.append("DAOImpl"); //$NON-NLS-1$
+ setDAOImplementationType(sb.toString());
+
+ sb.setLength(0);
+ sb.append(calculateJavaClientInterfacePackage());
+ sb.append('.');
+ sb.append(fullyQualifiedTable.getDomainObjectName());
+ sb.append("DAO"); //$NON-NLS-1$
+ setDAOInterfaceType(sb.toString());
+
+ sb.setLength(0);
+ sb.append(calculateJavaClientInterfacePackage());
+ sb.append('.');
+ if (stringHasValue(tableConfiguration.getMapperName())) {
+ //支持mapperName = "{0}Dao" 等用法
+ sb.append(MessageFormat.format(tableConfiguration.getMapperName(), fullyQualifiedTable.getDomainObjectName()));
+ } else {
+ sb.append(fullyQualifiedTable.getDomainObjectName());
+ sb.append("Mapper"); //$NON-NLS-1$
+ }
+ setMyBatis3JavaMapperType(sb.toString());
+
+ sb.setLength(0);
+ sb.append(calculateJavaClientInterfacePackage());
+ sb.append('.');
+ if (stringHasValue(tableConfiguration.getSqlProviderName())) {
+ //支持mapperName = "{0}SqlProvider" 等用法
+ sb.append(MessageFormat.format(tableConfiguration.getSqlProviderName(), fullyQualifiedTable.getDomainObjectName()));
+ } else {
+ sb.append(fullyQualifiedTable.getDomainObjectName());
+ sb.append("SqlProvider"); //$NON-NLS-1$
+ }
+ setMyBatis3SqlProviderType(sb.toString());
+ }
+}
diff --git a/generator/src/main/java/tk/mybatis/mapper/generator/TkMyBatis3SimpleImpl.java b/generator/src/main/java/tk/mybatis/mapper/generator/TkMyBatis3SimpleImpl.java
new file mode 100644
index 000000000..455b1e247
--- /dev/null
+++ b/generator/src/main/java/tk/mybatis/mapper/generator/TkMyBatis3SimpleImpl.java
@@ -0,0 +1,111 @@
+/*
+ * 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;
+
+import java.text.MessageFormat;
+
+import static org.mybatis.generator.internal.util.StringUtility.stringHasValue;
+
+/**
+ * 可以通过MBG1.3.4+版本提供的table元素的mapperName属性设置统一的名称,使用{0}作为实体类名的占位符。
+ *
+ *
+ *
+ * @author liuzh
+ * @since 2016-09-04 09:57
+ */
+public class TkMyBatis3SimpleImpl extends IntrospectedTableMyBatis3SimpleImpl {
+
+ @Override
+ protected String calculateMyBatis3XmlMapperFileName() {
+ StringBuilder sb = new StringBuilder();
+ if (stringHasValue(tableConfiguration.getMapperName())) {
+ String mapperName = tableConfiguration.getMapperName();
+ int ind = mapperName.lastIndexOf('.');
+ if (ind != -1) {
+ mapperName = mapperName.substring(ind + 1);
+ }
+ //支持mapperName = "{0}Dao" 等用法
+ sb.append(MessageFormat.format(mapperName, fullyQualifiedTable.getDomainObjectName()));
+ sb.append(".xml"); //$NON-NLS-1$
+ } else {
+ sb.append(fullyQualifiedTable.getDomainObjectName());
+ sb.append("Mapper.xml"); //$NON-NLS-1$
+ }
+ return sb.toString();
+ }
+
+ @Override
+ protected void calculateJavaClientAttributes() {
+ if (context.getJavaClientGeneratorConfiguration() == null) {
+ return;
+ }
+
+ StringBuilder sb = new StringBuilder();
+ sb.append(calculateJavaClientImplementationPackage());
+ sb.append('.');
+ sb.append(fullyQualifiedTable.getDomainObjectName());
+ sb.append("DAOImpl"); //$NON-NLS-1$
+ setDAOImplementationType(sb.toString());
+
+ sb.setLength(0);
+ sb.append(calculateJavaClientInterfacePackage());
+ sb.append('.');
+ sb.append(fullyQualifiedTable.getDomainObjectName());
+ sb.append("DAO"); //$NON-NLS-1$
+ setDAOInterfaceType(sb.toString());
+
+ sb.setLength(0);
+ sb.append(calculateJavaClientInterfacePackage());
+ sb.append('.');
+ if (stringHasValue(tableConfiguration.getMapperName())) {
+ //支持mapperName = "{0}Dao" 等用法
+ sb.append(MessageFormat.format(tableConfiguration.getMapperName(), fullyQualifiedTable.getDomainObjectName()));
+ } else {
+ sb.append(fullyQualifiedTable.getDomainObjectName());
+ sb.append("Mapper"); //$NON-NLS-1$
+ }
+ setMyBatis3JavaMapperType(sb.toString());
+
+ sb.setLength(0);
+ sb.append(calculateJavaClientInterfacePackage());
+ sb.append('.');
+ if (stringHasValue(tableConfiguration.getSqlProviderName())) {
+ //支持mapperName = "{0}SqlProvider" 等用法
+ sb.append(MessageFormat.format(tableConfiguration.getSqlProviderName(), fullyQualifiedTable.getDomainObjectName()));
+ } else {
+ sb.append(fullyQualifiedTable.getDomainObjectName());
+ sb.append("SqlProvider"); //$NON-NLS-1$
+ }
+ setMyBatis3SqlProviderType(sb.toString());
+ }
+}
diff --git a/generator/src/main/java/tk/mybatis/mapper/generator/file/GenerateByListTemplateFile.java b/generator/src/main/java/tk/mybatis/mapper/generator/file/GenerateByListTemplateFile.java
new file mode 100644
index 000000000..df419706f
--- /dev/null
+++ b/generator/src/main/java/tk/mybatis/mapper/generator/file/GenerateByListTemplateFile.java
@@ -0,0 +1,90 @@
+/*
+ * 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.file;
+
+import org.mybatis.generator.api.GeneratedJavaFile;
+import org.mybatis.generator.api.dom.java.CompilationUnit;
+import tk.mybatis.mapper.generator.formatter.ListTemplateFormatter;
+import tk.mybatis.mapper.generator.model.TableClass;
+
+import java.util.Properties;
+import java.util.Set;
+
+/**
+ * @author liuzh
+ * @since 3.4.5
+ */
+public class GenerateByListTemplateFile extends GeneratedJavaFile {
+ public static final String ENCODING = "UTF-8";
+
+ private String targetPackage;
+
+ private String fileNameTemplate;
+
+ private String templateContent;
+
+ private Properties properties;
+
+ private Set tableClassSet;
+
+ private ListTemplateFormatter templateFormatter;
+
+ public GenerateByListTemplateFile(Set tableClassSet, ListTemplateFormatter templateFormatter, Properties properties, String targetProject, String targetPackage, String fileNameTemplate, String templateContent) {
+ super(null, targetProject, ENCODING, null);
+ this.targetProject = targetProject;
+ this.targetPackage = targetPackage;
+ this.fileNameTemplate = fileNameTemplate;
+ this.templateContent = templateContent;
+ this.properties = properties;
+ this.tableClassSet = tableClassSet;
+ this.templateFormatter = templateFormatter;
+ }
+
+ @Override
+ public CompilationUnit getCompilationUnit() {
+ return null;
+ }
+
+ @Override
+ public String getFileName() {
+ return templateFormatter.getFormattedContent(tableClassSet, properties, targetPackage, fileNameTemplate);
+ }
+
+ @Override
+ public String getFormattedContent() {
+ return templateFormatter.getFormattedContent(tableClassSet, properties, targetPackage, templateContent);
+ }
+
+ @Override
+ public String getTargetPackage() {
+ return targetPackage;
+ }
+
+ @Override
+ public boolean isMergeable() {
+ return false;
+ }
+
+}
diff --git a/generator/src/main/java/tk/mybatis/mapper/generator/file/GenerateByTemplateFile.java b/generator/src/main/java/tk/mybatis/mapper/generator/file/GenerateByTemplateFile.java
new file mode 100644
index 000000000..0fa76950f
--- /dev/null
+++ b/generator/src/main/java/tk/mybatis/mapper/generator/file/GenerateByTemplateFile.java
@@ -0,0 +1,89 @@
+/*
+ * 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.file;
+
+import org.mybatis.generator.api.GeneratedJavaFile;
+import org.mybatis.generator.api.dom.java.CompilationUnit;
+import tk.mybatis.mapper.generator.formatter.TemplateFormatter;
+import tk.mybatis.mapper.generator.model.TableClass;
+
+import java.util.Properties;
+
+/**
+ * @author liuzh
+ * @since 3.4.5
+ */
+public class GenerateByTemplateFile extends GeneratedJavaFile {
+ public static final String ENCODING = "UTF-8";
+
+ private String targetPackage;
+
+ private String fileName;
+
+ private String templateContent;
+
+ private Properties properties;
+
+ private TableClass tableClass;
+
+ private TemplateFormatter templateFormatter;
+
+ public GenerateByTemplateFile(TableClass tableClass, TemplateFormatter templateFormatter, Properties properties, String targetProject, String targetPackage, String fileName, String templateContent) {
+ super(null, targetProject, ENCODING, null);
+ this.targetProject = targetProject;
+ this.targetPackage = targetPackage;
+ this.fileName = fileName;
+ this.templateContent = templateContent;
+ this.properties = properties;
+ this.tableClass = tableClass;
+ this.templateFormatter = templateFormatter;
+ }
+
+ @Override
+ public CompilationUnit getCompilationUnit() {
+ return null;
+ }
+
+ @Override
+ public String getFileName() {
+ return templateFormatter.getFormattedContent(tableClass, properties, targetPackage, fileName);
+ }
+
+ @Override
+ public String getFormattedContent() {
+ return templateFormatter.getFormattedContent(tableClass, properties, targetPackage, templateContent);
+ }
+
+ @Override
+ public String getTargetPackage() {
+ return templateFormatter.getFormattedContent(tableClass, properties, targetPackage, targetPackage);
+ }
+
+ @Override
+ public boolean isMergeable() {
+ return false;
+ }
+
+}
diff --git a/generator/src/main/java/tk/mybatis/mapper/generator/formatter/FreemarkerTemplateFormatter.java b/generator/src/main/java/tk/mybatis/mapper/generator/formatter/FreemarkerTemplateFormatter.java
new file mode 100644
index 000000000..cf96809d6
--- /dev/null
+++ b/generator/src/main/java/tk/mybatis/mapper/generator/formatter/FreemarkerTemplateFormatter.java
@@ -0,0 +1,97 @@
+/*
+ * 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.formatter;
+
+
+import freemarker.cache.StringTemplateLoader;
+import freemarker.template.Configuration;
+import freemarker.template.DefaultObjectWrapper;
+import freemarker.template.Template;
+import tk.mybatis.mapper.generator.model.TableClass;
+
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.*;
+
+/**
+ * 基于 freemarker 的实现
+ *
+ * @author liuzh
+ * @since 3.4.5
+ */
+public class FreemarkerTemplateFormatter implements TemplateFormatter, ListTemplateFormatter {
+ private final Configuration configuration = new Configuration(Configuration.VERSION_2_3_23);
+ private final StringTemplateLoader templateLoader = new StringTemplateLoader();
+
+ public FreemarkerTemplateFormatter() {
+ configuration.setLocale(Locale.CHINA);
+ configuration.setDefaultEncoding("UTF-8");
+ configuration.setTemplateLoader(templateLoader);
+ configuration.setObjectWrapper(new DefaultObjectWrapper(Configuration.VERSION_2_3_23));
+ }
+
+ /**
+ * 根据模板处理
+ *
+ * @param templateName
+ * @param templateSource
+ * @param params
+ * @return
+ */
+ public String process(String templateName, String templateSource, Map params) {
+ try {
+ Template template = new Template(templateName, templateSource, configuration);
+ Writer writer = new StringWriter();
+ template.process(params, writer);
+ return writer.toString();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public String getFormattedContent(TableClass tableClass, Properties properties, String targetPackage, String templateContent) {
+ Map params = new HashMap();
+ for (Object o : properties.keySet()) {
+ params.put(String.valueOf(o), properties.get(o));
+ }
+ params.put("props", properties);
+ params.put("package", targetPackage);
+ params.put("tableClass", tableClass);
+ return process(properties.getProperty("templatePath"), templateContent, params);
+ }
+
+ @Override
+ public String getFormattedContent(Set tableClassSet, Properties properties, String targetPackage, String templateContent) {
+ Map params = new HashMap();
+ for (Object o : properties.keySet()) {
+ params.put(String.valueOf(o), properties.get(o));
+ }
+ params.put("props", properties);
+ params.put("package", targetPackage);
+ params.put("tableClassSet", tableClassSet);
+ return process(properties.getProperty("templatePath"), templateContent, params);
+ }
+}
diff --git a/generator/src/main/java/tk/mybatis/mapper/generator/formatter/ListTemplateFormatter.java b/generator/src/main/java/tk/mybatis/mapper/generator/formatter/ListTemplateFormatter.java
new file mode 100644
index 000000000..b78983d8c
--- /dev/null
+++ b/generator/src/main/java/tk/mybatis/mapper/generator/formatter/ListTemplateFormatter.java
@@ -0,0 +1,48 @@
+/*
+ * 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.formatter;
+
+import tk.mybatis.mapper.generator.model.TableClass;
+
+import java.util.Properties;
+import java.util.Set;
+
+/**
+ * @author liuzh
+ * @since 3.4.5
+ */
+public interface ListTemplateFormatter {
+
+ /**
+ * 获取根据模板生成的数据
+ *
+ * @param tableClassSet
+ * @param properties
+ * @param targetPackage
+ * @param templateContent
+ * @return
+ */
+ String getFormattedContent(Set tableClassSet, Properties properties, String targetPackage, String templateContent);
+}
diff --git a/generator/src/main/java/tk/mybatis/mapper/generator/formatter/TemplateFormatter.java b/generator/src/main/java/tk/mybatis/mapper/generator/formatter/TemplateFormatter.java
new file mode 100644
index 000000000..7c0d6256e
--- /dev/null
+++ b/generator/src/main/java/tk/mybatis/mapper/generator/formatter/TemplateFormatter.java
@@ -0,0 +1,47 @@
+/*
+ * 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.formatter;
+
+import tk.mybatis.mapper.generator.model.TableClass;
+
+import java.util.Properties;
+
+/**
+ * @author liuzh
+ * @since 3.4.5
+ */
+public interface TemplateFormatter {
+
+ /**
+ * 获取根据模板生成的数据
+ *
+ * @param tableClass
+ * @param properties
+ * @param targetPackage
+ * @param templateContent
+ * @return
+ */
+ String getFormattedContent(TableClass tableClass, Properties properties, String targetPackage, String templateContent);
+}
diff --git a/generator/src/main/java/tk/mybatis/mapper/generator/model/ColumnField.java b/generator/src/main/java/tk/mybatis/mapper/generator/model/ColumnField.java
new file mode 100644
index 000000000..bda744062
--- /dev/null
+++ b/generator/src/main/java/tk/mybatis/mapper/generator/model/ColumnField.java
@@ -0,0 +1,209 @@
+/*
+ * 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.model;
+
+import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
+
+import java.io.Serializable;
+
+/**
+ * @author liuzh
+ * @since 3.4.5
+ */
+public class ColumnField implements Serializable {
+
+ private static final long serialVersionUID = -435113788623615260L;
+ private TableClass tableClass;
+ private String columnName;
+ private String jdbcType;
+ private String fieldName;
+ private String remarks;
+ private FullyQualifiedJavaType type;
+ private String typePackage;
+ private String shortTypeName;
+ private String fullTypeName;
+ private boolean identity;
+ private boolean nullable;
+ private boolean blobColumn;
+ private boolean stringColumn;
+ private boolean jdbcCharacterColumn;
+ private boolean jdbcDateColumn;
+ private boolean jdbcTimeColumn;
+ private boolean sequenceColumn;
+ private int length;
+ private int scale;
+
+ public String getColumnName() {
+ return columnName;
+ }
+
+ public void setColumnName(String columnName) {
+ this.columnName = columnName;
+ }
+
+ public String getFieldName() {
+ return fieldName;
+ }
+
+ public void setFieldName(String fieldName) {
+ this.fieldName = fieldName;
+ }
+
+ public String getFullTypeName() {
+ return fullTypeName;
+ }
+
+ public void setFullTypeName(String fullTypeName) {
+ this.fullTypeName = fullTypeName;
+ }
+
+ public String getJdbcType() {
+ return jdbcType;
+ }
+
+ public void setJdbcType(String jdbcType) {
+ this.jdbcType = jdbcType;
+ }
+
+ public int getLength() {
+ return length;
+ }
+
+ public void setLength(int length) {
+ this.length = length;
+ }
+
+ public String getRemarks() {
+ return remarks;
+ }
+
+ public void setRemarks(String remarks) {
+ this.remarks = remarks;
+ }
+
+ public int getScale() {
+ return scale;
+ }
+
+ public void setScale(int scale) {
+ this.scale = scale;
+ }
+
+ public String getShortTypeName() {
+ return shortTypeName;
+ }
+
+ public void setShortTypeName(String shortTypeName) {
+ this.shortTypeName = shortTypeName;
+ }
+
+ public TableClass getTableClass() {
+ return tableClass;
+ }
+
+ public void setTableClass(TableClass tableClass) {
+ this.tableClass = tableClass;
+ }
+
+ public FullyQualifiedJavaType getType() {
+ return type;
+ }
+
+ public void setType(FullyQualifiedJavaType type) {
+ this.type = type;
+ }
+
+ public String getTypePackage() {
+ return typePackage;
+ }
+
+ public void setTypePackage(String typePackage) {
+ this.typePackage = typePackage;
+ }
+
+ public boolean isBlobColumn() {
+ return blobColumn;
+ }
+
+ public void setBlobColumn(boolean blobColumn) {
+ this.blobColumn = blobColumn;
+ }
+
+ public boolean isIdentity() {
+ return identity;
+ }
+
+ public void setIdentity(boolean identity) {
+ this.identity = identity;
+ }
+
+ public boolean isJdbcCharacterColumn() {
+ return jdbcCharacterColumn;
+ }
+
+ public void setJdbcCharacterColumn(boolean jdbcCharacterColumn) {
+ this.jdbcCharacterColumn = jdbcCharacterColumn;
+ }
+
+ public boolean isJdbcDateColumn() {
+ return jdbcDateColumn;
+ }
+
+ public void setJdbcDateColumn(boolean jdbcDateColumn) {
+ this.jdbcDateColumn = jdbcDateColumn;
+ }
+
+ public boolean isJdbcTimeColumn() {
+ return jdbcTimeColumn;
+ }
+
+ public void setJdbcTimeColumn(boolean jdbcTimeColumn) {
+ this.jdbcTimeColumn = jdbcTimeColumn;
+ }
+
+ public boolean isNullable() {
+ return nullable;
+ }
+
+ public void setNullable(boolean nullable) {
+ this.nullable = nullable;
+ }
+
+ public boolean isSequenceColumn() {
+ return sequenceColumn;
+ }
+
+ public void setSequenceColumn(boolean sequenceColumn) {
+ this.sequenceColumn = sequenceColumn;
+ }
+
+ public boolean isStringColumn() {
+ return stringColumn;
+ }
+
+ public void setStringColumn(boolean stringColumn) {
+ this.stringColumn = stringColumn;
+ }
+}
diff --git a/generator/src/main/java/tk/mybatis/mapper/generator/model/TableClass.java b/generator/src/main/java/tk/mybatis/mapper/generator/model/TableClass.java
new file mode 100644
index 000000000..2668bc5d1
--- /dev/null
+++ b/generator/src/main/java/tk/mybatis/mapper/generator/model/TableClass.java
@@ -0,0 +1,150 @@
+/*
+ * 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.model;
+
+import org.mybatis.generator.api.IntrospectedTable;
+import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author liuzh
+ * @since 3.4.5
+ */
+public class TableClass implements Serializable {
+ private static final long serialVersionUID = -746251813735169289L;
+
+ private IntrospectedTable introspectedTable;
+
+ private String tableName;
+ private String variableName;
+ private String lowerCaseName;
+ private String shortClassName;
+ private String fullClassName;
+ private String packageName;
+ private FullyQualifiedJavaType type;
+
+ private List pkFields;
+ private List baseFields;
+ private List blobFields;
+ private List allFields;
+
+ public List getAllFields() {
+ return allFields;
+ }
+
+ public void setAllFields(List allFields) {
+ this.allFields = allFields;
+ }
+
+ public List getBaseFields() {
+ return baseFields;
+ }
+
+ public void setBaseFields(List baseFields) {
+ this.baseFields = baseFields;
+ }
+
+ public List getBlobFields() {
+ return blobFields;
+ }
+
+ public void setBlobFields(List blobFields) {
+ this.blobFields = blobFields;
+ }
+
+ public String getFullClassName() {
+ return fullClassName;
+ }
+
+ public void setFullClassName(String fullClassName) {
+ this.fullClassName = fullClassName;
+ }
+
+ public IntrospectedTable getIntrospectedTable() {
+ return introspectedTable;
+ }
+
+ public void setIntrospectedTable(IntrospectedTable introspectedTable) {
+ this.introspectedTable = introspectedTable;
+ }
+
+ public String getLowerCaseName() {
+ return lowerCaseName;
+ }
+
+ public void setLowerCaseName(String lowerCaseName) {
+ this.lowerCaseName = lowerCaseName;
+ }
+
+ public String getPackageName() {
+ return packageName;
+ }
+
+ public void setPackageName(String packageName) {
+ this.packageName = packageName;
+ }
+
+ public List getPkFields() {
+ return pkFields;
+ }
+
+ public void setPkFields(List pkFields) {
+ this.pkFields = pkFields;
+ }
+
+ public String getShortClassName() {
+ return shortClassName;
+ }
+
+ public void setShortClassName(String shortClassName) {
+ this.shortClassName = shortClassName;
+ }
+
+ public String getTableName() {
+ return tableName;
+ }
+
+ public void setTableName(String tableName) {
+ this.tableName = tableName;
+ }
+
+ public FullyQualifiedJavaType getType() {
+ return type;
+ }
+
+ public void setType(FullyQualifiedJavaType type) {
+ this.type = type;
+ }
+
+ public String getVariableName() {
+ return variableName;
+ }
+
+ public void setVariableName(String variableName) {
+ this.variableName = variableName;
+ }
+}
diff --git a/generator/src/main/java/tk/mybatis/mapper/generator/model/TableColumnBuilder.java b/generator/src/main/java/tk/mybatis/mapper/generator/model/TableColumnBuilder.java
new file mode 100644
index 000000000..7c0ceca5f
--- /dev/null
+++ b/generator/src/main/java/tk/mybatis/mapper/generator/model/TableColumnBuilder.java
@@ -0,0 +1,124 @@
+/*
+ * 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.model;
+
+import org.mybatis.generator.api.FullyQualifiedTable;
+import org.mybatis.generator.api.IntrospectedColumn;
+import org.mybatis.generator.api.IntrospectedTable;
+import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
+
+import java.beans.Introspector;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author liuzh
+ * @since 3.4.5
+ */
+public class TableColumnBuilder {
+
+ /**
+ * 创建 TableClass
+ *
+ * @param introspectedTable
+ * @return
+ */
+ public static TableClass build(IntrospectedTable introspectedTable) {
+ TableClass tableClass = new TableClass();
+ tableClass.setIntrospectedTable(introspectedTable);
+
+ FullyQualifiedTable fullyQualifiedTable = introspectedTable.getFullyQualifiedTable();
+ tableClass.setTableName(fullyQualifiedTable.getIntrospectedTableName());
+
+ FullyQualifiedJavaType type = new FullyQualifiedJavaType(introspectedTable.getBaseRecordType());
+ tableClass.setType(type);
+ tableClass.setVariableName(Introspector.decapitalize(type.getShortName()));
+ tableClass.setLowerCaseName(type.getShortName().toLowerCase());
+ tableClass.setShortClassName(type.getShortName());
+ tableClass.setFullClassName(type.getFullyQualifiedName());
+ tableClass.setPackageName(type.getPackageName());
+
+ List pkFields = new ArrayList();
+ List baseFields = new ArrayList();
+ List blobFields = new ArrayList();
+ List allFields = new ArrayList();
+ for (IntrospectedColumn column : introspectedTable.getPrimaryKeyColumns()) {
+ ColumnField field = build(column);
+ field.setTableClass(tableClass);
+ pkFields.add(field);
+ allFields.add(field);
+ }
+ for (IntrospectedColumn column : introspectedTable.getBaseColumns()) {
+ ColumnField field = build(column);
+ field.setTableClass(tableClass);
+ baseFields.add(field);
+ allFields.add(field);
+ }
+ for (IntrospectedColumn column : introspectedTable.getBLOBColumns()) {
+ ColumnField field = build(column);
+ field.setTableClass(tableClass);
+ blobFields.add(field);
+ allFields.add(field);
+ }
+ tableClass.setPkFields(pkFields);
+ tableClass.setBaseFields(baseFields);
+ tableClass.setBlobFields(blobFields);
+ tableClass.setAllFields(allFields);
+
+ return tableClass;
+ }
+
+ /**
+ * 创建 ColumnField
+ *
+ * @param column
+ * @return
+ */
+ public static ColumnField build(IntrospectedColumn column) {
+ ColumnField field = new ColumnField();
+ field.setColumnName(column.getActualColumnName());
+ field.setJdbcType(column.getJdbcTypeName());
+ field.setFieldName(column.getJavaProperty());
+ field.setRemarks(column.getRemarks());
+ FullyQualifiedJavaType type = column.getFullyQualifiedJavaType();
+ field.setType(type);
+ field.setTypePackage(type.getPackageName());
+ field.setShortTypeName(type.getShortName());
+ field.setFullTypeName(type.getFullyQualifiedName());
+ field.setIdentity(column.isIdentity());
+ field.setNullable(column.isNullable());
+ field.setSequenceColumn(column.isSequenceColumn());
+ field.setBlobColumn(column.isBLOBColumn());
+ field.setStringColumn(column.isStringColumn());
+ field.setJdbcCharacterColumn(column.isJdbcCharacterColumn());
+ field.setJdbcDateColumn(column.isJDBCDateColumn());
+ field.setJdbcTimeColumn(column.isJDBCTimeColumn());
+ field.setLength(column.getLength());
+ field.setScale(column.getScale());
+ return field;
+ }
+
+
+}
diff --git a/generator/src/main/resources/generator/mapper.ftl b/generator/src/main/resources/generator/mapper.ftl
new file mode 100644
index 000000000..49e0bb20f
--- /dev/null
+++ b/generator/src/main/resources/generator/mapper.ftl
@@ -0,0 +1,16 @@
+package ${package};
+
+import ${tableClass.fullClassName};
+
+/**
+* 通用 Mapper 代码生成器
+*
+* @author mapper-generator
+*/
+public interface ${tableClass.shortClassName}${mapperSuffix} extends ${baseMapper!"tk.mybatis.mapper.common.Mapper"}<${tableClass.shortClassName}> {
+
+}
+
+
+
+
diff --git a/generator/src/main/resources/generator/mapperXml.ftl b/generator/src/main/resources/generator/mapperXml.ftl
new file mode 100644
index 000000000..9c3994c24
--- /dev/null
+++ b/generator/src/main/resources/generator/mapperXml.ftl
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/generator/src/main/resources/generator/test-all.ftl b/generator/src/main/resources/generator/test-all.ftl
new file mode 100644
index 000000000..921153865
--- /dev/null
+++ b/generator/src/main/resources/generator/test-all.ftl
@@ -0,0 +1,112 @@
+目标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>
+
+<#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}
+ <#if field.remarks??>
+ 注释:${field.remarks}
+ #if>
+ 类型包名:${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}
+ <#if field.remarks??>
+ 注释:${field.remarks}
+ #if>
+ 类型包名:${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}
+ <#if field.remarks??>
+ 注释:${field.remarks}
+ #if>
+ 类型包名:${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/generator/src/main/resources/generator/test-one.ftl b/generator/src/main/resources/generator/test-one.ftl
new file mode 100644
index 000000000..b8cbb4a24
--- /dev/null
+++ b/generator/src/main/resources/generator/test-one.ftl
@@ -0,0 +1,109 @@
+目标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}
+ <#if field.remarks??>
+ 注释:${field.remarks}
+ #if>
+ 类型包名:${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}
+ <#if field.remarks??>
+ 注释:${field.remarks}
+ #if>
+ 类型包名:${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}
+ <#if field.remarks??>
+ 注释:${field.remarks}
+ #if>
+ 类型包名:${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/generator/src/test/java/tk/mybatis/mapper/generator/Generator.java b/generator/src/test/java/tk/mybatis/mapper/generator/Generator.java
new file mode 100644
index 000000000..8ec0e22f4
--- /dev/null
+++ b/generator/src/test/java/tk/mybatis/mapper/generator/Generator.java
@@ -0,0 +1,85 @@
+/*
+ * 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.hsqldb.cmdline.SqlFile;
+import org.mybatis.generator.api.MyBatisGenerator;
+import org.mybatis.generator.config.Configuration;
+import org.mybatis.generator.config.xml.ConfigurationParser;
+import org.mybatis.generator.internal.DefaultShellCallback;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.sql.*;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author liuzh
+ */
+public class Generator {
+
+ public static void startDB(){
+ try {
+ Class.forName("org.hsqldb.jdbcDriver");
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ }
+ String url = "jdbc:hsqldb:mem:generator";
+ String user = "sa";
+ String password = "";
+ try {
+ Connection connection = DriverManager.getConnection(url, user, password);
+ InputStream inputStream = getResourceAsStream("CreateDB.sql");
+
+ SqlFile sqlFile = new SqlFile(new InputStreamReader(inputStream), "init", System.out, "UTF-8", false, new File("."));
+ sqlFile.setConnection(connection);
+ sqlFile.execute();
+
+ connection.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static InputStream getResourceAsStream(String path){
+ return Thread.currentThread().getContextClassLoader().getResourceAsStream(path);
+ }
+
+ public static void main(String[] args) throws Exception {
+ startDB();
+ List warnings = new ArrayList();
+ boolean overwrite = true;
+ ConfigurationParser cp = new ConfigurationParser(warnings);
+ Configuration config = cp.parseConfiguration(getResourceAsStream("generatorConfig.xml"));
+ DefaultShellCallback callback = new DefaultShellCallback(overwrite);
+ MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
+ myBatisGenerator.generate(null);
+ for (String warning : warnings) {
+ System.out.println(warning);
+ }
+ }
+}
diff --git a/generator/src/test/resources/CreateDB.sql b/generator/src/test/resources/CreateDB.sql
new file mode 100644
index 000000000..7048a45a7
--- /dev/null
+++ b/generator/src/test/resources/CreateDB.sql
@@ -0,0 +1,43 @@
+drop table country if exists;
+
+create table country (
+ id integer NOT NULL PRIMARY KEY,
+ countryname varchar(32),
+ countrycode VARCHAR(2) DEFAULT 'HH',
+ version INTEGER DEFAULT 1 NOT NULL
+);
+
+drop table user_info if exists;
+
+--用户信息表
+create table user_info (
+ id integer GENERATED BY DEFAULT AS IDENTITY(START WITH 6) NOT NULL PRIMARY KEY,
+ username varchar(32) NOT NULL,
+ password varchar(32) DEFAULT '12345678',
+ usertype varchar(2),
+ enabled integer,
+ realname varchar(50),
+ qq varchar(12),
+ email varchar(100),
+ address varchar(200),
+ tel varchar(30)
+);
+
+insert into user_info (id,username,password,usertype) values (1,'test1','12345678','1');
+insert into user_info (id,username,password,usertype) values (2,'test2','aaaa','2');
+insert into user_info (id,username,password,usertype) values (3,'test3','bbbb','1');
+insert into user_info (id,username,password,usertype) values (4,'test4','cccc','2');
+insert into user_info (id,username,password,usertype) values (5,'test5','dddd','1');
+
+INSERT INTO country (id, countryname, countrycode, version) VALUES (1, 'Angola', 'AO', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (2, 'Afghanistan', 'AF', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (3, 'Albania', 'AL', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (4, 'Algeria', 'DZ', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (5, 'Andorra', 'AD', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (6, 'Anguilla', 'AI', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (7, 'Antigua and Barbuda', 'AG', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (8, 'Argentina', 'AR', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (9, 'Armenia', 'AM', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (10, 'Australia', 'AU', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (11, 'Austria', 'AT', 1);
+INSERT INTO country (id, countryname, countrycode, version) VALUES (12, 'Azerbaijan', 'AZ', 1);
\ No newline at end of file
diff --git a/generator/src/test/resources/generatorConfig.xml b/generator/src/test/resources/generatorConfig.xml
new file mode 100644
index 000000000..dba4a9c49
--- /dev/null
+++ b/generator/src/test/resources/generatorConfig.xml
@@ -0,0 +1,97 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index c39bfe023..65c8f52b5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,7 +1,7 @@
+
+ generator
+ spring-boot-starter
+
- 1.1.2
+ UTF-8
+
+ 1.6
+ 1.0
+ 1.7.25
+ 3.4.5
+
+ 4.12
+ 1.2.17
+ 2.2.9
+
+
+
+ javax.persistence
+ persistence-api
+ ${jpa.version}
+
+
+
+
+ org.mybatis
+ mybatis
+ ${mybatis.version}
+ provided
+
+
+ org.slf4j
+ slf4j-api
+ ${slf4j.version}
+ provided
+
+
+
+
+ junit
+ junit
+ ${junit.version}
+ test
+
+
+ log4j
+ log4j
+ ${log4j.version}
+ test
+
+
+ org.hsqldb
+ hsqldb
+ ${hsqldb.version}
+ test
+
+
+
+
-
+
- javax.persistence
- persistence-api
+ junit
+ junit
-
-
- org.mybatis
- mybatis
+ log4j
+ log4j
+
+
+ org.hsqldb
+ hsqldb
+
+
+
+
+ src/test/resources
+
+
+ src/test/java
+
+
+
+
+ maven-compiler-plugin
+
+ ${jdk.version}
+ ${jdk.version}
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+
+
+ package
+
+ jar-no-fork
+
+
+
+
+
+
+
+
+ release
+
+ all
+ base
+ core
+ extra
+ spring
+ weekend
+ generator
+ spring-boot-starter
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 2.9
+
+
+ package
+
+ jar
+
+
+ -Xdoclint:none
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-gpg-plugin
+
+
+ sign-artifacts
+ verify
+
+ sign
+
+
+
+
+
+
+
+
+ oss
+ https://oss.sonatype.org/content/repositories/snapshots/
+
+
+ oss
+ https://oss.sonatype.org/service/local/staging/deploy/maven2/
+
+
+
+
diff --git a/spring-boot-starter/README.md b/spring-boot-starter/README.md
new file mode 100644
index 000000000..307bd7acb
--- /dev/null
+++ b/spring-boot-starter/README.md
@@ -0,0 +1,120 @@
+# MyBatis Mapper integration with Spring Boot
+
+[](https://maven-badges.herokuapp.com/maven-central/tk.mybatis/mapper-spring-boot-starter)
+
+Mapper-Spring-Boot-Starter 帮助你集成通用 Mapper 到 Spring Boot。
+
+Mapper-Spring-Boot-Starter will help you use Mapper with Spring Boot.
+
+## How to use
+在 pom.xml 中添加如下依赖:
+
+Add the following dependency to your pom.xml:
+```xml
+
+ tk.mybatis
+ mapper-spring-boot-starter
+ 1.2.3
+
+```
+
+## 1.2.3 - 2018-01-24
+
+- 增加 `tk.mybatis.spring.mapper.SpringBootBindUtil`,使用原生方式兼容 Spring Boot 1.x 和 2.x 版本,已经不存在 relax 值问题,以前的配置不需要修改即可使用。
+- 特别注意,如果使用了 `@MapperScan` 注解,请使用 `tk.mybatis.spring.annotation.MapperScan` 注解。
+- 通用 Mapper 升级到 3.5.2 版本。
+
+## 1.2.2
+
+- 由于 weekend 版本依赖问题,这个版本存在问题,不作为正式发布版本。
+
+## 1.2.1 - 2018-01-10
+
+- 为了增强兼容性,`MapperAutoConfiguration` 增加 `@AutoConfigureBefore(name = "org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration")`
+即使依赖中存在 MyBatis 的 starter,Mapper 也可以优先使用自动配置,MyBatis后续就不会触发生成 `@Bean`
+
+- 支持简单的 relax 绑定,例如 not-empty 会转换为 notEmpty 使用,兼容 spring boot 配置方式
+
+
+## 1.2.0 - 2018-01-08
+
+- 通用 Mapper 3.5.0
+- 去掉 mybatis-spring-boot-starter 依赖,不在使用 mybatis 官方 starter,使用通用 Mapper 时不要再引入官方 starter
+- 参考 mybatis 官方 starter 重新实现,解决 mapper 初始化可能存在的问题 [pr#5 by fengcbo](https://github.com/abel533/mapper-boot-starter/pull/5)
+- 如果需要使用 `@MapperScan` 请选择 tk 开头的 `tk.mybatis.spring.annotation.MapperScan`
+
+## 1.1.7 - 2017-12-17
+
+- 通用 Mapper 3.4.6
+- spring-boot 1.5.9.RELEASE
+
+## 1.1.6 - 2017-11-11
+
+- 通用 Mapper 3.4.5
+
+## 1.1.5 - 2017-10-21
+
+- 通用 Mapper 3.4.4
+- mybatis-starter 1.3.1
+- spring-boot 1.5.8.RELEASE
+
+## 1.1.4 - 2017-08-18
+
+- 通用 Mapper 3.4.3
+
+## 1.1.3 - 2017-07-18
+
+- 通用 Mapper 3.4.2
+
+## 1.1.2 - 2017-07-17
+
+- 通用 Mapper 3.4.1
+- mybatis 3.4.4
+- mybatis-spring-boot 1.3.0
+- spring-boot 1.5.4.RELEASE
+
+## 1.1.1 - 2017-03-28
+
+- 解决 1.1.0 版本不一致的问题
+- 增加对多数据源的支持,感谢 邱占波的 [PR #2](https://github.com/abel533/mapper-boot-starter/pull/2)
+
+## 1.1.0 - 2017-02-19
+
+- mybatis 升级到 3.4.2
+- mapper 升级到 3.4.0
+- mybatis-spring 升级到 1.3.1
+- mybatis-spring-boot 升级到 1.2.0
+- spring-boot 升级到 1.4.4.RELEASE
+
+## Example
+>https://github.com/abel533/MyBatis-Spring-Boot
+
+## Special Configurations
+一般情况下,你不需要做任何配置。
+
+Normally, you don't need to do any configuration.
+
+如果需要配置,可以使用如下方式进行配置:
+
+You can config PageHelper as the following:
+
+application.properties:
+```properties
+mapper.propertyName=propertyValue
+```
+
+示例:
+```properties
+mapper.mappers[0]=tk.mybatis.sample.mapper.BaseMapper
+mapper.mappers[1]=tk.mybatis.mapper.common.Mapper
+```
+默认情况下,没有 mappers 配置时,会自动注册 `tk.mybatis.mapper.common.Mapper`
+
+因为通用 Mapper 是固定的属性,所以接收参数使用的对象,按照 Spring Boot 配置规则,大写字母都变了带横线的小写字母。针对如 IDENTITY(对应i-d-e-n-t-i-t-y)提供了全小写的 identity 配置,如果 IDE 能自动提示,看自动提示即可。
+
+IDE 应该可以自动提示:
+
+
+
+## MyBatis Mapper
+>https://github.com/abel533/Mapper
diff --git a/spring-boot-starter/mapper-spring-boot-autoconfigure/pom.xml b/spring-boot-starter/mapper-spring-boot-autoconfigure/pom.xml
new file mode 100644
index 000000000..5ef1cc4b9
--- /dev/null
+++ b/spring-boot-starter/mapper-spring-boot-autoconfigure/pom.xml
@@ -0,0 +1,77 @@
+
+
+
+
+ 4.0.0
+
+ tk.mybatis
+ mapper-spring-boot
+ 1.2.3
+
+ mapper-spring-boot-autoconfigure
+ mapper-spring-boot-autoconfigure
+
+
+
+
+ org.springframework.boot
+ spring-boot-autoconfigure
+
+
+
+ tk.mybatis
+ mapper-core
+ true
+
+
+ tk.mybatis
+ mapper-spring
+ true
+
+
+ org.mybatis
+ mybatis
+ true
+
+
+ org.mybatis
+ mybatis-spring
+ true
+
+
+ org.slf4j
+ slf4j-api
+ true
+
+
+
+
+ org.springframework.boot
+ spring-boot-configuration-processor
+ true
+
+
+
diff --git a/spring-boot-starter/mapper-spring-boot-autoconfigure/src/main/java/tk/mybatis/mapper/autoconfigure/ConfigurationCustomizer.java b/spring-boot-starter/mapper-spring-boot-autoconfigure/src/main/java/tk/mybatis/mapper/autoconfigure/ConfigurationCustomizer.java
new file mode 100644
index 000000000..80c40ef67
--- /dev/null
+++ b/spring-boot-starter/mapper-spring-boot-autoconfigure/src/main/java/tk/mybatis/mapper/autoconfigure/ConfigurationCustomizer.java
@@ -0,0 +1,34 @@
+/**
+ * Copyright 2015-2017 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.
+ */
+package tk.mybatis.mapper.autoconfigure;
+
+import org.apache.ibatis.session.Configuration;
+
+/**
+ * Callback interface that can be customized a {@link Configuration} object generated on auto-configuration.
+ *
+ * @author Kazuki Shimizu
+ * @since 1.2.1
+ */
+public interface ConfigurationCustomizer {
+
+ /**
+ * Customize the given a {@link Configuration} object.
+ * @param configuration the configuration object to customize
+ */
+ void customize(Configuration configuration);
+
+}
diff --git a/spring-boot-starter/mapper-spring-boot-autoconfigure/src/main/java/tk/mybatis/mapper/autoconfigure/MapperAutoConfiguration.java b/spring-boot-starter/mapper-spring-boot-autoconfigure/src/main/java/tk/mybatis/mapper/autoconfigure/MapperAutoConfiguration.java
new file mode 100644
index 000000000..cd6b9adf9
--- /dev/null
+++ b/spring-boot-starter/mapper-spring-boot-autoconfigure/src/main/java/tk/mybatis/mapper/autoconfigure/MapperAutoConfiguration.java
@@ -0,0 +1,247 @@
+/**
+ * Copyright 2015-2017 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.
+ */
+package tk.mybatis.mapper.autoconfigure;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.mapping.DatabaseIdProvider;
+import org.apache.ibatis.plugin.Interceptor;
+import org.apache.ibatis.session.Configuration;
+import org.apache.ibatis.session.ExecutorType;
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.mybatis.spring.SqlSessionFactoryBean;
+import org.mybatis.spring.SqlSessionTemplate;
+import org.mybatis.spring.mapper.MapperFactoryBean;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanFactoryAware;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.AutoConfigureBefore;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.EnvironmentAware;
+import org.springframework.context.ResourceLoaderAware;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Import;
+import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
+import org.springframework.core.env.Environment;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.ResourceLoader;
+import org.springframework.core.type.AnnotationMetadata;
+import org.springframework.util.Assert;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.ObjectUtils;
+import org.springframework.util.StringUtils;
+import tk.mybatis.spring.mapper.ClassPathMapperScanner;
+
+import javax.annotation.PostConstruct;
+import javax.sql.DataSource;
+import java.util.List;
+
+/**
+ * {@link EnableAutoConfiguration Auto-Configuration} for Mybatis. Contributes a
+ * {@link SqlSessionFactory} and a {@link SqlSessionTemplate}.
+ *
+ * If {@link org.mybatis.spring.annotation.MapperScan} is used, or a
+ * configuration file is specified as a property, those will be considered,
+ * otherwise this auto-configuration will attempt to register mappers based on
+ * the interface definitions in or under the root auto-configuration package.
+ *
+ * @author Eddú Meléndez
+ * @author Josh Long
+ * @author Kazuki Shimizu
+ * @author Eduardo Macarrón
+ */
+@org.springframework.context.annotation.Configuration
+@ConditionalOnClass({SqlSessionFactory.class, SqlSessionFactoryBean.class})
+@ConditionalOnBean(DataSource.class)
+@EnableConfigurationProperties({MybatisProperties.class})
+@AutoConfigureAfter(DataSourceAutoConfiguration.class)
+@AutoConfigureBefore(name = "org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration")
+public class MapperAutoConfiguration {
+
+ private static final Logger logger = LoggerFactory.getLogger(MapperAutoConfiguration.class);
+
+ private final MybatisProperties properties;
+
+ private final Interceptor[] interceptors;
+
+ private final ResourceLoader resourceLoader;
+
+ private final DatabaseIdProvider databaseIdProvider;
+
+ private final List configurationCustomizers;
+
+ public MapperAutoConfiguration(MybatisProperties properties,
+ ObjectProvider interceptorsProvider,
+ ResourceLoader resourceLoader,
+ ObjectProvider databaseIdProvider,
+ ObjectProvider> configurationCustomizersProvider) {
+ this.properties = properties;
+ this.interceptors = interceptorsProvider.getIfAvailable();
+ this.resourceLoader = resourceLoader;
+ this.databaseIdProvider = databaseIdProvider.getIfAvailable();
+ this.configurationCustomizers = configurationCustomizersProvider.getIfAvailable();
+ }
+
+ @PostConstruct
+ public void checkConfigFileExists() {
+ if (this.properties.isCheckConfigLocation() && StringUtils.hasText(this.properties.getConfigLocation())) {
+ Resource resource = this.resourceLoader.getResource(this.properties.getConfigLocation());
+ Assert.state(resource.exists(), "Cannot find config location: " + resource
+ + " (please add config file or check your Mybatis configuration)");
+ }
+ }
+
+ @Bean
+ @ConditionalOnMissingBean
+ public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
+ SqlSessionFactoryBean factory = new SqlSessionFactoryBean();
+ factory.setDataSource(dataSource);
+ factory.setVfs(SpringBootVFS.class);
+ if (StringUtils.hasText(this.properties.getConfigLocation())) {
+ factory.setConfigLocation(this.resourceLoader.getResource(this.properties.getConfigLocation()));
+ }
+ Configuration configuration = this.properties.getConfiguration();
+ if (configuration == null && !StringUtils.hasText(this.properties.getConfigLocation())) {
+ configuration = new Configuration();
+ }
+ if (configuration != null && !CollectionUtils.isEmpty(this.configurationCustomizers)) {
+ for (ConfigurationCustomizer customizer : this.configurationCustomizers) {
+ customizer.customize(configuration);
+ }
+ }
+ factory.setConfiguration(configuration);
+ if (this.properties.getConfigurationProperties() != null) {
+ factory.setConfigurationProperties(this.properties.getConfigurationProperties());
+ }
+ if (!ObjectUtils.isEmpty(this.interceptors)) {
+ factory.setPlugins(this.interceptors);
+ }
+ if (this.databaseIdProvider != null) {
+ factory.setDatabaseIdProvider(this.databaseIdProvider);
+ }
+ if (StringUtils.hasLength(this.properties.getTypeAliasesPackage())) {
+ factory.setTypeAliasesPackage(this.properties.getTypeAliasesPackage());
+ }
+ if (StringUtils.hasLength(this.properties.getTypeHandlersPackage())) {
+ factory.setTypeHandlersPackage(this.properties.getTypeHandlersPackage());
+ }
+ if (!ObjectUtils.isEmpty(this.properties.resolveMapperLocations())) {
+ factory.setMapperLocations(this.properties.resolveMapperLocations());
+ }
+
+ return factory.getObject();
+ }
+
+ @Bean
+ @ConditionalOnMissingBean
+ public SqlSessionTemplate sqlSessionTemplate(SqlSessionFactory sqlSessionFactory) {
+ ExecutorType executorType = this.properties.getExecutorType();
+ if (executorType != null) {
+ return new SqlSessionTemplate(sqlSessionFactory, executorType);
+ } else {
+ return new SqlSessionTemplate(sqlSessionFactory);
+ }
+ }
+
+ /**
+ * This will just scan the same base package as Spring Boot does. If you want
+ * more power, you can explicitly use
+ * {@link org.mybatis.spring.annotation.MapperScan} but this will get typed
+ * mappers working correctly, out-of-the-box, similar to using Spring Data JPA
+ * repositories.
+ */
+ public static class AutoConfiguredMapperScannerRegistrar
+ implements BeanFactoryAware, ImportBeanDefinitionRegistrar, ResourceLoaderAware, EnvironmentAware {
+
+ private BeanFactory beanFactory;
+
+ private ResourceLoader resourceLoader;
+
+ private Environment environment;
+
+ @Override
+ public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
+
+ logger.debug("Searching for mappers annotated with @Mapper");
+
+ ClassPathMapperScanner scanner = new ClassPathMapperScanner(registry);
+ scanner.setMapperProperties(environment);
+ try {
+ if (this.resourceLoader != null) {
+ scanner.setResourceLoader(this.resourceLoader);
+ }
+
+ List packages = AutoConfigurationPackages.get(this.beanFactory);
+ if (logger.isDebugEnabled()) {
+ for (String pkg : packages) {
+ logger.debug("Using auto-configuration base package '{}'", pkg);
+ }
+ }
+
+ scanner.setAnnotationClass(Mapper.class);
+ scanner.registerFilters();
+ scanner.doScan(StringUtils.toStringArray(packages));
+ } catch (IllegalStateException ex) {
+ logger.debug("Could not determine auto-configuration package, automatic mapper scanning disabled.", ex);
+ }
+ }
+
+ @Override
+ public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
+ this.beanFactory = beanFactory;
+ }
+
+ @Override
+ public void setEnvironment(Environment environment) {
+ this.environment = environment;
+ }
+
+ @Override
+ public void setResourceLoader(ResourceLoader resourceLoader) {
+ this.resourceLoader = resourceLoader;
+ }
+ }
+
+ /**
+ * {@link org.mybatis.spring.annotation.MapperScan} ultimately ends up
+ * creating instances of {@link MapperFactoryBean}. If
+ * {@link org.mybatis.spring.annotation.MapperScan} is used then this
+ * auto-configuration is not needed. If it is _not_ used, however, then this
+ * will bring in a bean registrar and automatically register components based
+ * on the same component-scanning path as Spring Boot itself.
+ */
+ @org.springframework.context.annotation.Configuration
+ @Import({AutoConfiguredMapperScannerRegistrar.class})
+ @ConditionalOnMissingBean(MapperFactoryBean.class)
+ public static class MapperScannerRegistrarNotFoundConfiguration {
+
+ @PostConstruct
+ public void afterPropertiesSet() {
+ logger.debug("No {} found.", MapperFactoryBean.class.getName());
+ }
+ }
+
+}
diff --git a/spring-boot-starter/mapper-spring-boot-autoconfigure/src/main/java/tk/mybatis/mapper/autoconfigure/MapperProperties.java b/spring-boot-starter/mapper-spring-boot-autoconfigure/src/main/java/tk/mybatis/mapper/autoconfigure/MapperProperties.java
new file mode 100644
index 000000000..a421b8cf0
--- /dev/null
+++ b/spring-boot-starter/mapper-spring-boot-autoconfigure/src/main/java/tk/mybatis/mapper/autoconfigure/MapperProperties.java
@@ -0,0 +1,77 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 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.autoconfigure;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import tk.mybatis.mapper.entity.Config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * 这个类存在的主要目的是方便 IDE 自动提示 mapper. 开头的配置
+ *
+ * @author liuzh
+ * @since 2017/1/2.
+ */
+@ConfigurationProperties(prefix = MapperProperties.PREFIX)
+public class MapperProperties extends Config {
+ public static final String PREFIX = "mapper";
+
+ private List mappers = new ArrayList();
+
+ public String getIdentity() {
+ return getIDENTITY();
+ }
+
+ public void setIdentity(String identity) {
+ setIDENTITY(identity);
+ }
+
+ public List getMappers() {
+ return mappers;
+ }
+
+ public void setMappers(List mappers) {
+ this.mappers = mappers;
+ }
+
+ public String getUuid() {
+ return getUUID();
+ }
+
+ public void setUuid(String uuid) {
+ setUUID(uuid);
+ }
+
+ public boolean isBefore() {
+ return isBEFORE();
+ }
+
+ public void setBefore(boolean before) {
+ setBEFORE(before);
+ }
+}
diff --git a/spring-boot-starter/mapper-spring-boot-autoconfigure/src/main/java/tk/mybatis/mapper/autoconfigure/MybatisProperties.java b/spring-boot-starter/mapper-spring-boot-autoconfigure/src/main/java/tk/mybatis/mapper/autoconfigure/MybatisProperties.java
new file mode 100644
index 000000000..6263699f5
--- /dev/null
+++ b/spring-boot-starter/mapper-spring-boot-autoconfigure/src/main/java/tk/mybatis/mapper/autoconfigure/MybatisProperties.java
@@ -0,0 +1,186 @@
+/**
+ * Copyright 2015-2017 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.
+ */
+package tk.mybatis.mapper.autoconfigure;
+
+import org.apache.ibatis.session.Configuration;
+import org.apache.ibatis.session.ExecutorType;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.context.properties.NestedConfigurationProperty;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+import org.springframework.core.io.support.ResourcePatternResolver;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * Configuration properties for MyBatis.
+ *
+ * @author Eddú Meléndez
+ * @author Kazuki Shimizu
+ */
+@ConfigurationProperties(prefix = MybatisProperties.MYBATIS_PREFIX)
+public class MybatisProperties {
+
+ public static final String MYBATIS_PREFIX = "mybatis";
+
+ /**
+ * Location of MyBatis xml config file.
+ */
+ private String configLocation;
+
+ /**
+ * Locations of MyBatis mapper files.
+ */
+ private String[] mapperLocations;
+
+ /**
+ * Packages to search type aliases. (Package delimiters are ",; \t\n")
+ */
+ private String typeAliasesPackage;
+
+ /**
+ * Packages to search for type handlers. (Package delimiters are ",; \t\n")
+ */
+ private String typeHandlersPackage;
+
+ /**
+ * Indicates whether perform presence check of the MyBatis xml config file.
+ */
+ private boolean checkConfigLocation = false;
+
+ /**
+ * Execution mode for {@link org.mybatis.spring.SqlSessionTemplate}.
+ */
+ private ExecutorType executorType;
+
+ /**
+ * Externalized properties for MyBatis configuration.
+ */
+ private Properties configurationProperties;
+
+ /**
+ * A Configuration object for customize default settings. If {@link #configLocation}
+ * is specified, this property is not used.
+ */
+ @NestedConfigurationProperty
+ private Configuration configuration;
+
+ /**
+ * @since 1.1.0
+ */
+ public String getConfigLocation() {
+ return this.configLocation;
+ }
+
+ /**
+ * @since 1.1.0
+ */
+ public void setConfigLocation(String configLocation) {
+ this.configLocation = configLocation;
+ }
+
+ @Deprecated
+ public String getConfig() {
+ return this.configLocation;
+ }
+
+ @Deprecated
+ public void setConfig(String config) {
+ this.configLocation = config;
+ }
+
+ public String[] getMapperLocations() {
+ return this.mapperLocations;
+ }
+
+ public void setMapperLocations(String[] mapperLocations) {
+ this.mapperLocations = mapperLocations;
+ }
+
+ public String getTypeHandlersPackage() {
+ return this.typeHandlersPackage;
+ }
+
+ public void setTypeHandlersPackage(String typeHandlersPackage) {
+ this.typeHandlersPackage = typeHandlersPackage;
+ }
+
+ public String getTypeAliasesPackage() {
+ return this.typeAliasesPackage;
+ }
+
+ public void setTypeAliasesPackage(String typeAliasesPackage) {
+ this.typeAliasesPackage = typeAliasesPackage;
+ }
+
+ public boolean isCheckConfigLocation() {
+ return this.checkConfigLocation;
+ }
+
+ public void setCheckConfigLocation(boolean checkConfigLocation) {
+ this.checkConfigLocation = checkConfigLocation;
+ }
+
+ public ExecutorType getExecutorType() {
+ return this.executorType;
+ }
+
+ public void setExecutorType(ExecutorType executorType) {
+ this.executorType = executorType;
+ }
+
+ /**
+ * @since 1.2.0
+ */
+ public Properties getConfigurationProperties() {
+ return configurationProperties;
+ }
+
+ /**
+ * @since 1.2.0
+ */
+ public void setConfigurationProperties(Properties configurationProperties) {
+ this.configurationProperties = configurationProperties;
+ }
+
+ public Configuration getConfiguration() {
+ return configuration;
+ }
+
+ public void setConfiguration(Configuration configuration) {
+ this.configuration = configuration;
+ }
+
+ public Resource[] resolveMapperLocations() {
+ ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
+ List resources = new ArrayList();
+ if (this.mapperLocations != null) {
+ for (String mapperLocation : this.mapperLocations) {
+ try {
+ Resource[] mappers = resourceResolver.getResources(mapperLocation);
+ resources.addAll(Arrays.asList(mappers));
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+ return resources.toArray(new Resource[resources.size()]);
+ }
+}
diff --git a/spring-boot-starter/mapper-spring-boot-autoconfigure/src/main/java/tk/mybatis/mapper/autoconfigure/SpringBootVFS.java b/spring-boot-starter/mapper-spring-boot-autoconfigure/src/main/java/tk/mybatis/mapper/autoconfigure/SpringBootVFS.java
new file mode 100644
index 000000000..79d023a64
--- /dev/null
+++ b/spring-boot-starter/mapper-spring-boot-autoconfigure/src/main/java/tk/mybatis/mapper/autoconfigure/SpringBootVFS.java
@@ -0,0 +1,63 @@
+/**
+ * Copyright 2015-2017 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.
+ */
+package tk.mybatis.mapper.autoconfigure;
+
+import org.apache.ibatis.io.VFS;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+import org.springframework.core.io.support.ResourcePatternResolver;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Hans Westerbeek
+ * @author Eddú Meléndez
+ * @author Kazuki Shimizu
+ */
+public class SpringBootVFS extends VFS {
+
+ private final ResourcePatternResolver resourceResolver;
+
+ public SpringBootVFS() {
+ this.resourceResolver = new PathMatchingResourcePatternResolver(getClass().getClassLoader());
+ }
+
+ @Override
+ public boolean isValid() {
+ return true;
+ }
+
+ @Override
+ protected List list(URL url, String path) throws IOException {
+ Resource[] resources = resourceResolver.getResources("classpath*:" + path + "/**/*.class");
+ List resourcePaths = new ArrayList();
+ for (Resource resource : resources) {
+ resourcePaths.add(preserveSubpackageName(resource.getURI(), path));
+ }
+ return resourcePaths;
+ }
+
+ private static String preserveSubpackageName(final URI uri, final String rootPath) {
+ final String uriStr = uri.toString();
+ final int start = uriStr.indexOf(rootPath);
+ return uriStr.substring(start);
+ }
+
+}
diff --git a/spring-boot-starter/mapper-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories b/spring-boot-starter/mapper-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories
new file mode 100644
index 000000000..39e242f48
--- /dev/null
+++ b/spring-boot-starter/mapper-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories
@@ -0,0 +1,3 @@
+# Auto Configure
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+tk.mybatis.mapper.autoconfigure.MapperAutoConfiguration
diff --git a/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-annotation/pom.xml b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-annotation/pom.xml
new file mode 100644
index 000000000..af2204e6b
--- /dev/null
+++ b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-annotation/pom.xml
@@ -0,0 +1,62 @@
+
+
+
+
+ 4.0.0
+
+ tk.mybatis
+ mapper-spring-boot-samples
+ 1.2.3
+
+ mapper-spring-boot-sample-annotation
+ jar
+ mapper-spring-boot-sample-annotation
+
+
+ org.slf4j
+ slf4j-api
+ runtime
+
+
+ tk.mybatis
+ mapper-spring-boot-starter
+
+
+ com.h2database
+ h2
+ runtime
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ ${spring-boot.version}
+
+
+
+
diff --git a/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-annotation/src/main/java/tk/mybatis/sample/SampleMapperApplication.java b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-annotation/src/main/java/tk/mybatis/sample/SampleMapperApplication.java
new file mode 100644
index 000000000..a0c25acf2
--- /dev/null
+++ b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-annotation/src/main/java/tk/mybatis/sample/SampleMapperApplication.java
@@ -0,0 +1,56 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 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.sample;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import tk.mybatis.sample.domain.Country;
+import tk.mybatis.sample.mapper.CountryMapper;
+import tk.mybatis.spring.annotation.MapperScan;
+
+import java.util.List;
+
+@MapperScan(basePackages = "tk.mybatis.sample.mapper")
+@SpringBootApplication
+public class SampleMapperApplication implements CommandLineRunner {
+
+ @Autowired
+ private CountryMapper countryMapper;
+
+ public static void main(String[] args) {
+ SpringApplication.run(SampleMapperApplication.class, args);
+ }
+
+ @Override
+ public void run(String... args) throws Exception {
+ List countries = countryMapper.selectAll();
+ for (Country country : countries) {
+ System.out.println("Country Name: " + country.getCountryname());
+ }
+ }
+
+}
diff --git a/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-annotation/src/main/java/tk/mybatis/sample/domain/Country.java b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-annotation/src/main/java/tk/mybatis/sample/domain/Country.java
new file mode 100644
index 000000000..d555fc7c0
--- /dev/null
+++ b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-annotation/src/main/java/tk/mybatis/sample/domain/Country.java
@@ -0,0 +1,69 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 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.sample.domain;
+
+import org.apache.ibatis.type.JdbcType;
+import tk.mybatis.mapper.annotation.ColumnType;
+
+import javax.persistence.Id;
+import java.io.Serializable;
+
+/**
+ * Description: Country
+ * Author: liuzh
+ * Update: liuzh(2014-06-06 13:38)
+ */
+public class Country implements Serializable {
+ private static final long serialVersionUID = 6569081236403751407L;
+ @Id
+ @ColumnType(jdbcType = JdbcType.BIGINT)
+ private Long id;
+ private String countryname;
+ private String countrycode;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getCountryname() {
+ return countryname;
+ }
+
+ public void setCountryname(String countryname) {
+ this.countryname = countryname;
+ }
+
+ public String getCountrycode() {
+ return countrycode;
+ }
+
+ public void setCountrycode(String countrycode) {
+ this.countrycode = countrycode;
+ }
+}
diff --git a/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-annotation/src/main/java/tk/mybatis/sample/mapper/CountryMapper.java b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-annotation/src/main/java/tk/mybatis/sample/mapper/CountryMapper.java
new file mode 100644
index 000000000..d036c492d
--- /dev/null
+++ b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-annotation/src/main/java/tk/mybatis/sample/mapper/CountryMapper.java
@@ -0,0 +1,33 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 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.sample.mapper;
+
+import org.apache.ibatis.annotations.Mapper;
+import tk.mybatis.sample.domain.Country;
+
+@Mapper
+public interface CountryMapper extends tk.mybatis.mapper.common.Mapper {
+
+}
diff --git a/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-annotation/src/main/resources/application.properties b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-annotation/src/main/resources/application.properties
new file mode 100644
index 000000000..a077c532c
--- /dev/null
+++ b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-annotation/src/main/resources/application.properties
@@ -0,0 +1,26 @@
+#
+# The MIT License (MIT)
+#
+# Copyright (c) 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.
+#
+spring.datasource.schema=import.sql
+logging.level.root=WARN
+logging.level.tk.mybatis.sample.mapper=TRACE
\ No newline at end of file
diff --git a/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-annotation/src/main/resources/import.sql b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-annotation/src/main/resources/import.sql
new file mode 100644
index 000000000..2e7e7c544
--- /dev/null
+++ b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-annotation/src/main/resources/import.sql
@@ -0,0 +1,191 @@
+drop table country if exists;
+
+create table country (
+ id int primary key auto_increment,
+ countryname varchar(32),
+ countrycode varchar(2)
+);
+
+insert into country (id, countryname, countrycode) values(1,'Angola','AO');
+insert into country (id, countryname, countrycode) values(2,'Afghanistan','AF');
+insert into country (id, countryname, countrycode) values(3,'Albania','AL');
+insert into country (id, countryname, countrycode) values(4,'Algeria','DZ');
+insert into country (id, countryname, countrycode) values(5,'Andorra','AD');
+insert into country (id, countryname, countrycode) values(6,'Anguilla','AI');
+insert into country (id, countryname, countrycode) values(7,'Antigua and Barbuda','AG');
+insert into country (id, countryname, countrycode) values(8,'Argentina','AR');
+insert into country (id, countryname, countrycode) values(9,'Armenia','AM');
+insert into country (id, countryname, countrycode) values(10,'Australia','AU');
+insert into country (id, countryname, countrycode) values(11,'Austria','AT');
+insert into country (id, countryname, countrycode) values(12,'Azerbaijan','AZ');
+insert into country (id, countryname, countrycode) values(13,'Bahamas','BS');
+insert into country (id, countryname, countrycode) values(14,'Bahrain','BH');
+insert into country (id, countryname, countrycode) values(15,'Bangladesh','BD');
+insert into country (id, countryname, countrycode) values(16,'Barbados','BB');
+insert into country (id, countryname, countrycode) values(17,'Belarus','BY');
+insert into country (id, countryname, countrycode) values(18,'Belgium','BE');
+insert into country (id, countryname, countrycode) values(19,'Belize','BZ');
+insert into country (id, countryname, countrycode) values(20,'Benin','BJ');
+insert into country (id, countryname, countrycode) values(21,'Bermuda Is.','BM');
+insert into country (id, countryname, countrycode) values(22,'Bolivia','BO');
+insert into country (id, countryname, countrycode) values(23,'Botswana','BW');
+insert into country (id, countryname, countrycode) values(24,'Brazil','BR');
+insert into country (id, countryname, countrycode) values(25,'Brunei','BN');
+insert into country (id, countryname, countrycode) values(26,'Bulgaria','BG');
+insert into country (id, countryname, countrycode) values(27,'Burkina-faso','BF');
+insert into country (id, countryname, countrycode) values(28,'Burma','MM');
+insert into country (id, countryname, countrycode) values(29,'Burundi','BI');
+insert into country (id, countryname, countrycode) values(30,'Cameroon','CM');
+insert into country (id, countryname, countrycode) values(31,'Canada','CA');
+insert into country (id, countryname, countrycode) values(32,'Central African Republic','CF');
+insert into country (id, countryname, countrycode) values(33,'Chad','TD');
+insert into country (id, countryname, countrycode) values(34,'Chile','CL');
+insert into country (id, countryname, countrycode) values(35,'China','CN');
+insert into country (id, countryname, countrycode) values(36,'Colombia','CO');
+insert into country (id, countryname, countrycode) values(37,'Congo','CG');
+insert into country (id, countryname, countrycode) values(38,'Cook Is.','CK');
+insert into country (id, countryname, countrycode) values(39,'Costa Rica','CR');
+insert into country (id, countryname, countrycode) values(40,'Cuba','CU');
+insert into country (id, countryname, countrycode) values(41,'Cyprus','CY');
+insert into country (id, countryname, countrycode) values(42,'Czech Republic','CZ');
+insert into country (id, countryname, countrycode) values(43,'Denmark','DK');
+insert into country (id, countryname, countrycode) values(44,'Djibouti','DJ');
+insert into country (id, countryname, countrycode) values(45,'Dominica Rep.','DO');
+insert into country (id, countryname, countrycode) values(46,'Ecuador','EC');
+insert into country (id, countryname, countrycode) values(47,'Egypt','EG');
+insert into country (id, countryname, countrycode) values(48,'EI Salvador','SV');
+insert into country (id, countryname, countrycode) values(49,'Estonia','EE');
+insert into country (id, countryname, countrycode) values(50,'Ethiopia','ET');
+insert into country (id, countryname, countrycode) values(51,'Fiji','FJ');
+insert into country (id, countryname, countrycode) values(52,'Finland','FI');
+insert into country (id, countryname, countrycode) values(53,'France','FR');
+insert into country (id, countryname, countrycode) values(54,'French Guiana','GF');
+insert into country (id, countryname, countrycode) values(55,'Gabon','GA');
+insert into country (id, countryname, countrycode) values(56,'Gambia','GM');
+insert into country (id, countryname, countrycode) values(57,'Georgia','GE');
+insert into country (id, countryname, countrycode) values(58,'Germany','DE');
+insert into country (id, countryname, countrycode) values(59,'Ghana','GH');
+insert into country (id, countryname, countrycode) values(60,'Gibraltar','GI');
+insert into country (id, countryname, countrycode) values(61,'Greece','GR');
+insert into country (id, countryname, countrycode) values(62,'Grenada','GD');
+insert into country (id, countryname, countrycode) values(63,'Guam','GU');
+insert into country (id, countryname, countrycode) values(64,'Guatemala','GT');
+insert into country (id, countryname, countrycode) values(65,'Guinea','GN');
+insert into country (id, countryname, countrycode) values(66,'Guyana','GY');
+insert into country (id, countryname, countrycode) values(67,'Haiti','HT');
+insert into country (id, countryname, countrycode) values(68,'Honduras','HN');
+insert into country (id, countryname, countrycode) values(69,'Hongkong','HK');
+insert into country (id, countryname, countrycode) values(70,'Hungary','HU');
+insert into country (id, countryname, countrycode) values(71,'Iceland','IS');
+insert into country (id, countryname, countrycode) values(72,'India','IN');
+insert into country (id, countryname, countrycode) values(73,'Indonesia','ID');
+insert into country (id, countryname, countrycode) values(74,'Iran','IR');
+insert into country (id, countryname, countrycode) values(75,'Iraq','IQ');
+insert into country (id, countryname, countrycode) values(76,'Ireland','IE');
+insert into country (id, countryname, countrycode) values(77,'Israel','IL');
+insert into country (id, countryname, countrycode) values(78,'Italy','IT');
+insert into country (id, countryname, countrycode) values(79,'Jamaica','JM');
+insert into country (id, countryname, countrycode) values(80,'Japan','JP');
+insert into country (id, countryname, countrycode) values(81,'Jordan','JO');
+insert into country (id, countryname, countrycode) values(82,'Kampuchea (Cambodia )','KH');
+insert into country (id, countryname, countrycode) values(83,'Kazakstan','KZ');
+insert into country (id, countryname, countrycode) values(84,'Kenya','KE');
+insert into country (id, countryname, countrycode) values(85,'Korea','KR');
+insert into country (id, countryname, countrycode) values(86,'Kuwait','KW');
+insert into country (id, countryname, countrycode) values(87,'Kyrgyzstan','KG');
+insert into country (id, countryname, countrycode) values(88,'Laos','LA');
+insert into country (id, countryname, countrycode) values(89,'Latvia','LV');
+insert into country (id, countryname, countrycode) values(90,'Lebanon','LB');
+insert into country (id, countryname, countrycode) values(91,'Lesotho','LS');
+insert into country (id, countryname, countrycode) values(92,'Liberia','LR');
+insert into country (id, countryname, countrycode) values(93,'Libya','LY');
+insert into country (id, countryname, countrycode) values(94,'Liechtenstein','LI');
+insert into country (id, countryname, countrycode) values(95,'Lithuania','LT');
+insert into country (id, countryname, countrycode) values(96,'Luxembourg','LU');
+insert into country (id, countryname, countrycode) values(97,'Macao','MO');
+insert into country (id, countryname, countrycode) values(98,'Madagascar','MG');
+insert into country (id, countryname, countrycode) values(99,'Malawi','MW');
+insert into country (id, countryname, countrycode) values(100,'Malaysia','MY');
+insert into country (id, countryname, countrycode) values(101,'Maldives','MV');
+insert into country (id, countryname, countrycode) values(102,'Mali','ML');
+insert into country (id, countryname, countrycode) values(103,'Malta','MT');
+insert into country (id, countryname, countrycode) values(104,'Mauritius','MU');
+insert into country (id, countryname, countrycode) values(105,'Mexico','MX');
+insert into country (id, countryname, countrycode) values(106,'Moldova, Republic of','MD');
+insert into country (id, countryname, countrycode) values(107,'Monaco','MC');
+insert into country (id, countryname, countrycode) values(108,'Mongolia','MN');
+insert into country (id, countryname, countrycode) values(109,'Montserrat Is','MS');
+insert into country (id, countryname, countrycode) values(110,'Morocco','MA');
+insert into country (id, countryname, countrycode) values(111,'Mozambique','MZ');
+insert into country (id, countryname, countrycode) values(112,'Namibia','NA');
+insert into country (id, countryname, countrycode) values(113,'Nauru','NR');
+insert into country (id, countryname, countrycode) values(114,'Nepal','NP');
+insert into country (id, countryname, countrycode) values(115,'Netherlands','NL');
+insert into country (id, countryname, countrycode) values(116,'New Zealand','NZ');
+insert into country (id, countryname, countrycode) values(117,'Nicaragua','NI');
+insert into country (id, countryname, countrycode) values(118,'Niger','NE');
+insert into country (id, countryname, countrycode) values(119,'Nigeria','NG');
+insert into country (id, countryname, countrycode) values(120,'North Korea','KP');
+insert into country (id, countryname, countrycode) values(121,'Norway','NO');
+insert into country (id, countryname, countrycode) values(122,'Oman','OM');
+insert into country (id, countryname, countrycode) values(123,'Pakistan','PK');
+insert into country (id, countryname, countrycode) values(124,'Panama','PA');
+insert into country (id, countryname, countrycode) values(125,'Papua New Cuinea','PG');
+insert into country (id, countryname, countrycode) values(126,'Paraguay','PY');
+insert into country (id, countryname, countrycode) values(127,'Peru','PE');
+insert into country (id, countryname, countrycode) values(128,'Philippines','PH');
+insert into country (id, countryname, countrycode) values(129,'Poland','PL');
+insert into country (id, countryname, countrycode) values(130,'French Polynesia','PF');
+insert into country (id, countryname, countrycode) values(131,'Portugal','PT');
+insert into country (id, countryname, countrycode) values(132,'Puerto Rico','PR');
+insert into country (id, countryname, countrycode) values(133,'Qatar','QA');
+insert into country (id, countryname, countrycode) values(134,'Romania','RO');
+insert into country (id, countryname, countrycode) values(135,'Russia','RU');
+insert into country (id, countryname, countrycode) values(136,'Saint Lueia','LC');
+insert into country (id, countryname, countrycode) values(137,'Saint Vincent','VC');
+insert into country (id, countryname, countrycode) values(138,'San Marino','SM');
+insert into country (id, countryname, countrycode) values(139,'Sao Tome and Principe','ST');
+insert into country (id, countryname, countrycode) values(140,'Saudi Arabia','SA');
+insert into country (id, countryname, countrycode) values(141,'Senegal','SN');
+insert into country (id, countryname, countrycode) values(142,'Seychelles','SC');
+insert into country (id, countryname, countrycode) values(143,'Sierra Leone','SL');
+insert into country (id, countryname, countrycode) values(144,'Singapore','SG');
+insert into country (id, countryname, countrycode) values(145,'Slovakia','SK');
+insert into country (id, countryname, countrycode) values(146,'Slovenia','SI');
+insert into country (id, countryname, countrycode) values(147,'Solomon Is','SB');
+insert into country (id, countryname, countrycode) values(148,'Somali','SO');
+insert into country (id, countryname, countrycode) values(149,'South Africa','ZA');
+insert into country (id, countryname, countrycode) values(150,'Spain','ES');
+insert into country (id, countryname, countrycode) values(151,'Sri Lanka','LK');
+insert into country (id, countryname, countrycode) values(152,'St.Lucia','LC');
+insert into country (id, countryname, countrycode) values(153,'St.Vincent','VC');
+insert into country (id, countryname, countrycode) values(154,'Sudan','SD');
+insert into country (id, countryname, countrycode) values(155,'Suriname','SR');
+insert into country (id, countryname, countrycode) values(156,'Swaziland','SZ');
+insert into country (id, countryname, countrycode) values(157,'Sweden','SE');
+insert into country (id, countryname, countrycode) values(158,'Switzerland','CH');
+insert into country (id, countryname, countrycode) values(159,'Syria','SY');
+insert into country (id, countryname, countrycode) values(160,'Taiwan','TW');
+insert into country (id, countryname, countrycode) values(161,'Tajikstan','TJ');
+insert into country (id, countryname, countrycode) values(162,'Tanzania','TZ');
+insert into country (id, countryname, countrycode) values(163,'Thailand','TH');
+insert into country (id, countryname, countrycode) values(164,'Togo','TG');
+insert into country (id, countryname, countrycode) values(165,'Tonga','TO');
+insert into country (id, countryname, countrycode) values(166,'Trinidad and Tobago','TT');
+insert into country (id, countryname, countrycode) values(167,'Tunisia','TN');
+insert into country (id, countryname, countrycode) values(168,'Turkey','TR');
+insert into country (id, countryname, countrycode) values(169,'Turkmenistan','TM');
+insert into country (id, countryname, countrycode) values(170,'Uganda','UG');
+insert into country (id, countryname, countrycode) values(171,'Ukraine','UA');
+insert into country (id, countryname, countrycode) values(172,'United Arab Emirates','AE');
+insert into country (id, countryname, countrycode) values(173,'United Kiongdom','GB');
+insert into country (id, countryname, countrycode) values(174,'United States of America','US');
+insert into country (id, countryname, countrycode) values(175,'Uruguay','UY');
+insert into country (id, countryname, countrycode) values(176,'Uzbekistan','UZ');
+insert into country (id, countryname, countrycode) values(177,'Venezuela','VE');
+insert into country (id, countryname, countrycode) values(178,'Vietnam','VN');
+insert into country (id, countryname, countrycode) values(179,'Yemen','YE');
+insert into country (id, countryname, countrycode) values(180,'Yugoslavia','YU');
+insert into country (id, countryname, countrycode) values(181,'Zimbabwe','ZW');
+insert into country (id, countryname, countrycode) values(182,'Zaire','ZR');
+insert into country (id, countryname, countrycode) values(183,'Zambia','ZM');
\ No newline at end of file
diff --git a/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-xml/pom.xml b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-xml/pom.xml
new file mode 100644
index 000000000..23d70f0f9
--- /dev/null
+++ b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-xml/pom.xml
@@ -0,0 +1,62 @@
+
+
+
+
+ 4.0.0
+
+ tk.mybatis
+ mapper-spring-boot-samples
+ 1.2.3
+
+ mapper-spring-boot-sample-xml
+ jar
+ mapper-spring-boot-sample-xml
+
+
+ org.slf4j
+ slf4j-api
+ runtime
+
+
+ tk.mybatis
+ mapper-spring-boot-starter
+
+
+ com.h2database
+ h2
+ runtime
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ ${spring-boot.version}
+
+
+
+
diff --git a/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-xml/src/main/java/tk/mybatis/sample/SampleXmlApplication.java b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-xml/src/main/java/tk/mybatis/sample/SampleXmlApplication.java
new file mode 100644
index 000000000..8473e4443
--- /dev/null
+++ b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-xml/src/main/java/tk/mybatis/sample/SampleXmlApplication.java
@@ -0,0 +1,61 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 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.sample;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import tk.mybatis.sample.domain.Country;
+import tk.mybatis.sample.mapper.CountryMapper;
+
+import java.util.List;
+
+@SpringBootApplication
+//@MapperScan(basePackages = "tk.mybatis.sample", annotationClass = Mapper.class )
+public class SampleXmlApplication implements CommandLineRunner {
+
+ @Autowired
+ private CountryMapper countryMapper;
+
+ public static void main(String[] args) {
+ SpringApplication.run(SampleXmlApplication.class, args);
+ }
+
+ @Override
+ public void run(String... args) throws Exception {
+ Country c = countryMapper.selectByPrimaryKey(1);
+ System.out.println("Key : 1, Country Name: " + c.getCountryname());
+ c.setId(null);
+ c.setCountryname("新名字");
+ countryMapper.insert(c);
+ System.out.println("New Key: " + c.getId());
+ List countries = countryMapper.selectAll();
+ for (Country country : countries) {
+ System.out.println("Country Name: " + country.getCountryname());
+ }
+ }
+
+}
diff --git a/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-xml/src/main/java/tk/mybatis/sample/domain/Country.java b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-xml/src/main/java/tk/mybatis/sample/domain/Country.java
new file mode 100644
index 000000000..d555fc7c0
--- /dev/null
+++ b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-xml/src/main/java/tk/mybatis/sample/domain/Country.java
@@ -0,0 +1,69 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 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.sample.domain;
+
+import org.apache.ibatis.type.JdbcType;
+import tk.mybatis.mapper.annotation.ColumnType;
+
+import javax.persistence.Id;
+import java.io.Serializable;
+
+/**
+ * Description: Country
+ * Author: liuzh
+ * Update: liuzh(2014-06-06 13:38)
+ */
+public class Country implements Serializable {
+ private static final long serialVersionUID = 6569081236403751407L;
+ @Id
+ @ColumnType(jdbcType = JdbcType.BIGINT)
+ private Long id;
+ private String countryname;
+ private String countrycode;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getCountryname() {
+ return countryname;
+ }
+
+ public void setCountryname(String countryname) {
+ this.countryname = countryname;
+ }
+
+ public String getCountrycode() {
+ return countrycode;
+ }
+
+ public void setCountrycode(String countrycode) {
+ this.countrycode = countrycode;
+ }
+}
diff --git a/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-xml/src/main/java/tk/mybatis/sample/mapper/BaseMapper.java b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-xml/src/main/java/tk/mybatis/sample/mapper/BaseMapper.java
new file mode 100644
index 000000000..5c996d650
--- /dev/null
+++ b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-xml/src/main/java/tk/mybatis/sample/mapper/BaseMapper.java
@@ -0,0 +1,35 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 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.sample.mapper;
+
+import tk.mybatis.mapper.common.Mapper;
+
+/**
+ * @author liuzh
+ * @since 2017/1/2.
+ */
+public interface BaseMapper extends Mapper {
+
+}
diff --git a/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-xml/src/main/java/tk/mybatis/sample/mapper/CountryMapper.java b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-xml/src/main/java/tk/mybatis/sample/mapper/CountryMapper.java
new file mode 100644
index 000000000..e554f5296
--- /dev/null
+++ b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-xml/src/main/java/tk/mybatis/sample/mapper/CountryMapper.java
@@ -0,0 +1,40 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 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.sample.mapper;
+
+import org.apache.ibatis.annotations.Mapper;
+import tk.mybatis.sample.domain.Country;
+
+import java.util.List;
+
+/**
+ * @author Eduardo Macarron
+ */
+@Mapper
+public interface CountryMapper extends BaseMapper {
+
+ List findAll();
+
+}
diff --git a/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-xml/src/main/resources/application.properties b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-xml/src/main/resources/application.properties
new file mode 100644
index 000000000..9803c0dd5
--- /dev/null
+++ b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-xml/src/main/resources/application.properties
@@ -0,0 +1,32 @@
+#
+# The MIT License (MIT)
+#
+# Copyright (c) 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.
+#
+spring.datasource.schema=import.sql
+mybatis.config-location=mybatis-config.xml
+
+logging.level.root=WARN
+logging.level.tk.mybatis.sample.mapper=TRACE
+mapper.not-empty=true
+mapper.b-e-f-o-r-e=true
+mapper.mappers[0]=tk.mybatis.sample.mapper.BaseMapper
+mapper.mappers[1]=tk.mybatis.mapper.common.Mapper
\ No newline at end of file
diff --git a/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-xml/src/main/resources/import.sql b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-xml/src/main/resources/import.sql
new file mode 100644
index 000000000..2e7e7c544
--- /dev/null
+++ b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-xml/src/main/resources/import.sql
@@ -0,0 +1,191 @@
+drop table country if exists;
+
+create table country (
+ id int primary key auto_increment,
+ countryname varchar(32),
+ countrycode varchar(2)
+);
+
+insert into country (id, countryname, countrycode) values(1,'Angola','AO');
+insert into country (id, countryname, countrycode) values(2,'Afghanistan','AF');
+insert into country (id, countryname, countrycode) values(3,'Albania','AL');
+insert into country (id, countryname, countrycode) values(4,'Algeria','DZ');
+insert into country (id, countryname, countrycode) values(5,'Andorra','AD');
+insert into country (id, countryname, countrycode) values(6,'Anguilla','AI');
+insert into country (id, countryname, countrycode) values(7,'Antigua and Barbuda','AG');
+insert into country (id, countryname, countrycode) values(8,'Argentina','AR');
+insert into country (id, countryname, countrycode) values(9,'Armenia','AM');
+insert into country (id, countryname, countrycode) values(10,'Australia','AU');
+insert into country (id, countryname, countrycode) values(11,'Austria','AT');
+insert into country (id, countryname, countrycode) values(12,'Azerbaijan','AZ');
+insert into country (id, countryname, countrycode) values(13,'Bahamas','BS');
+insert into country (id, countryname, countrycode) values(14,'Bahrain','BH');
+insert into country (id, countryname, countrycode) values(15,'Bangladesh','BD');
+insert into country (id, countryname, countrycode) values(16,'Barbados','BB');
+insert into country (id, countryname, countrycode) values(17,'Belarus','BY');
+insert into country (id, countryname, countrycode) values(18,'Belgium','BE');
+insert into country (id, countryname, countrycode) values(19,'Belize','BZ');
+insert into country (id, countryname, countrycode) values(20,'Benin','BJ');
+insert into country (id, countryname, countrycode) values(21,'Bermuda Is.','BM');
+insert into country (id, countryname, countrycode) values(22,'Bolivia','BO');
+insert into country (id, countryname, countrycode) values(23,'Botswana','BW');
+insert into country (id, countryname, countrycode) values(24,'Brazil','BR');
+insert into country (id, countryname, countrycode) values(25,'Brunei','BN');
+insert into country (id, countryname, countrycode) values(26,'Bulgaria','BG');
+insert into country (id, countryname, countrycode) values(27,'Burkina-faso','BF');
+insert into country (id, countryname, countrycode) values(28,'Burma','MM');
+insert into country (id, countryname, countrycode) values(29,'Burundi','BI');
+insert into country (id, countryname, countrycode) values(30,'Cameroon','CM');
+insert into country (id, countryname, countrycode) values(31,'Canada','CA');
+insert into country (id, countryname, countrycode) values(32,'Central African Republic','CF');
+insert into country (id, countryname, countrycode) values(33,'Chad','TD');
+insert into country (id, countryname, countrycode) values(34,'Chile','CL');
+insert into country (id, countryname, countrycode) values(35,'China','CN');
+insert into country (id, countryname, countrycode) values(36,'Colombia','CO');
+insert into country (id, countryname, countrycode) values(37,'Congo','CG');
+insert into country (id, countryname, countrycode) values(38,'Cook Is.','CK');
+insert into country (id, countryname, countrycode) values(39,'Costa Rica','CR');
+insert into country (id, countryname, countrycode) values(40,'Cuba','CU');
+insert into country (id, countryname, countrycode) values(41,'Cyprus','CY');
+insert into country (id, countryname, countrycode) values(42,'Czech Republic','CZ');
+insert into country (id, countryname, countrycode) values(43,'Denmark','DK');
+insert into country (id, countryname, countrycode) values(44,'Djibouti','DJ');
+insert into country (id, countryname, countrycode) values(45,'Dominica Rep.','DO');
+insert into country (id, countryname, countrycode) values(46,'Ecuador','EC');
+insert into country (id, countryname, countrycode) values(47,'Egypt','EG');
+insert into country (id, countryname, countrycode) values(48,'EI Salvador','SV');
+insert into country (id, countryname, countrycode) values(49,'Estonia','EE');
+insert into country (id, countryname, countrycode) values(50,'Ethiopia','ET');
+insert into country (id, countryname, countrycode) values(51,'Fiji','FJ');
+insert into country (id, countryname, countrycode) values(52,'Finland','FI');
+insert into country (id, countryname, countrycode) values(53,'France','FR');
+insert into country (id, countryname, countrycode) values(54,'French Guiana','GF');
+insert into country (id, countryname, countrycode) values(55,'Gabon','GA');
+insert into country (id, countryname, countrycode) values(56,'Gambia','GM');
+insert into country (id, countryname, countrycode) values(57,'Georgia','GE');
+insert into country (id, countryname, countrycode) values(58,'Germany','DE');
+insert into country (id, countryname, countrycode) values(59,'Ghana','GH');
+insert into country (id, countryname, countrycode) values(60,'Gibraltar','GI');
+insert into country (id, countryname, countrycode) values(61,'Greece','GR');
+insert into country (id, countryname, countrycode) values(62,'Grenada','GD');
+insert into country (id, countryname, countrycode) values(63,'Guam','GU');
+insert into country (id, countryname, countrycode) values(64,'Guatemala','GT');
+insert into country (id, countryname, countrycode) values(65,'Guinea','GN');
+insert into country (id, countryname, countrycode) values(66,'Guyana','GY');
+insert into country (id, countryname, countrycode) values(67,'Haiti','HT');
+insert into country (id, countryname, countrycode) values(68,'Honduras','HN');
+insert into country (id, countryname, countrycode) values(69,'Hongkong','HK');
+insert into country (id, countryname, countrycode) values(70,'Hungary','HU');
+insert into country (id, countryname, countrycode) values(71,'Iceland','IS');
+insert into country (id, countryname, countrycode) values(72,'India','IN');
+insert into country (id, countryname, countrycode) values(73,'Indonesia','ID');
+insert into country (id, countryname, countrycode) values(74,'Iran','IR');
+insert into country (id, countryname, countrycode) values(75,'Iraq','IQ');
+insert into country (id, countryname, countrycode) values(76,'Ireland','IE');
+insert into country (id, countryname, countrycode) values(77,'Israel','IL');
+insert into country (id, countryname, countrycode) values(78,'Italy','IT');
+insert into country (id, countryname, countrycode) values(79,'Jamaica','JM');
+insert into country (id, countryname, countrycode) values(80,'Japan','JP');
+insert into country (id, countryname, countrycode) values(81,'Jordan','JO');
+insert into country (id, countryname, countrycode) values(82,'Kampuchea (Cambodia )','KH');
+insert into country (id, countryname, countrycode) values(83,'Kazakstan','KZ');
+insert into country (id, countryname, countrycode) values(84,'Kenya','KE');
+insert into country (id, countryname, countrycode) values(85,'Korea','KR');
+insert into country (id, countryname, countrycode) values(86,'Kuwait','KW');
+insert into country (id, countryname, countrycode) values(87,'Kyrgyzstan','KG');
+insert into country (id, countryname, countrycode) values(88,'Laos','LA');
+insert into country (id, countryname, countrycode) values(89,'Latvia','LV');
+insert into country (id, countryname, countrycode) values(90,'Lebanon','LB');
+insert into country (id, countryname, countrycode) values(91,'Lesotho','LS');
+insert into country (id, countryname, countrycode) values(92,'Liberia','LR');
+insert into country (id, countryname, countrycode) values(93,'Libya','LY');
+insert into country (id, countryname, countrycode) values(94,'Liechtenstein','LI');
+insert into country (id, countryname, countrycode) values(95,'Lithuania','LT');
+insert into country (id, countryname, countrycode) values(96,'Luxembourg','LU');
+insert into country (id, countryname, countrycode) values(97,'Macao','MO');
+insert into country (id, countryname, countrycode) values(98,'Madagascar','MG');
+insert into country (id, countryname, countrycode) values(99,'Malawi','MW');
+insert into country (id, countryname, countrycode) values(100,'Malaysia','MY');
+insert into country (id, countryname, countrycode) values(101,'Maldives','MV');
+insert into country (id, countryname, countrycode) values(102,'Mali','ML');
+insert into country (id, countryname, countrycode) values(103,'Malta','MT');
+insert into country (id, countryname, countrycode) values(104,'Mauritius','MU');
+insert into country (id, countryname, countrycode) values(105,'Mexico','MX');
+insert into country (id, countryname, countrycode) values(106,'Moldova, Republic of','MD');
+insert into country (id, countryname, countrycode) values(107,'Monaco','MC');
+insert into country (id, countryname, countrycode) values(108,'Mongolia','MN');
+insert into country (id, countryname, countrycode) values(109,'Montserrat Is','MS');
+insert into country (id, countryname, countrycode) values(110,'Morocco','MA');
+insert into country (id, countryname, countrycode) values(111,'Mozambique','MZ');
+insert into country (id, countryname, countrycode) values(112,'Namibia','NA');
+insert into country (id, countryname, countrycode) values(113,'Nauru','NR');
+insert into country (id, countryname, countrycode) values(114,'Nepal','NP');
+insert into country (id, countryname, countrycode) values(115,'Netherlands','NL');
+insert into country (id, countryname, countrycode) values(116,'New Zealand','NZ');
+insert into country (id, countryname, countrycode) values(117,'Nicaragua','NI');
+insert into country (id, countryname, countrycode) values(118,'Niger','NE');
+insert into country (id, countryname, countrycode) values(119,'Nigeria','NG');
+insert into country (id, countryname, countrycode) values(120,'North Korea','KP');
+insert into country (id, countryname, countrycode) values(121,'Norway','NO');
+insert into country (id, countryname, countrycode) values(122,'Oman','OM');
+insert into country (id, countryname, countrycode) values(123,'Pakistan','PK');
+insert into country (id, countryname, countrycode) values(124,'Panama','PA');
+insert into country (id, countryname, countrycode) values(125,'Papua New Cuinea','PG');
+insert into country (id, countryname, countrycode) values(126,'Paraguay','PY');
+insert into country (id, countryname, countrycode) values(127,'Peru','PE');
+insert into country (id, countryname, countrycode) values(128,'Philippines','PH');
+insert into country (id, countryname, countrycode) values(129,'Poland','PL');
+insert into country (id, countryname, countrycode) values(130,'French Polynesia','PF');
+insert into country (id, countryname, countrycode) values(131,'Portugal','PT');
+insert into country (id, countryname, countrycode) values(132,'Puerto Rico','PR');
+insert into country (id, countryname, countrycode) values(133,'Qatar','QA');
+insert into country (id, countryname, countrycode) values(134,'Romania','RO');
+insert into country (id, countryname, countrycode) values(135,'Russia','RU');
+insert into country (id, countryname, countrycode) values(136,'Saint Lueia','LC');
+insert into country (id, countryname, countrycode) values(137,'Saint Vincent','VC');
+insert into country (id, countryname, countrycode) values(138,'San Marino','SM');
+insert into country (id, countryname, countrycode) values(139,'Sao Tome and Principe','ST');
+insert into country (id, countryname, countrycode) values(140,'Saudi Arabia','SA');
+insert into country (id, countryname, countrycode) values(141,'Senegal','SN');
+insert into country (id, countryname, countrycode) values(142,'Seychelles','SC');
+insert into country (id, countryname, countrycode) values(143,'Sierra Leone','SL');
+insert into country (id, countryname, countrycode) values(144,'Singapore','SG');
+insert into country (id, countryname, countrycode) values(145,'Slovakia','SK');
+insert into country (id, countryname, countrycode) values(146,'Slovenia','SI');
+insert into country (id, countryname, countrycode) values(147,'Solomon Is','SB');
+insert into country (id, countryname, countrycode) values(148,'Somali','SO');
+insert into country (id, countryname, countrycode) values(149,'South Africa','ZA');
+insert into country (id, countryname, countrycode) values(150,'Spain','ES');
+insert into country (id, countryname, countrycode) values(151,'Sri Lanka','LK');
+insert into country (id, countryname, countrycode) values(152,'St.Lucia','LC');
+insert into country (id, countryname, countrycode) values(153,'St.Vincent','VC');
+insert into country (id, countryname, countrycode) values(154,'Sudan','SD');
+insert into country (id, countryname, countrycode) values(155,'Suriname','SR');
+insert into country (id, countryname, countrycode) values(156,'Swaziland','SZ');
+insert into country (id, countryname, countrycode) values(157,'Sweden','SE');
+insert into country (id, countryname, countrycode) values(158,'Switzerland','CH');
+insert into country (id, countryname, countrycode) values(159,'Syria','SY');
+insert into country (id, countryname, countrycode) values(160,'Taiwan','TW');
+insert into country (id, countryname, countrycode) values(161,'Tajikstan','TJ');
+insert into country (id, countryname, countrycode) values(162,'Tanzania','TZ');
+insert into country (id, countryname, countrycode) values(163,'Thailand','TH');
+insert into country (id, countryname, countrycode) values(164,'Togo','TG');
+insert into country (id, countryname, countrycode) values(165,'Tonga','TO');
+insert into country (id, countryname, countrycode) values(166,'Trinidad and Tobago','TT');
+insert into country (id, countryname, countrycode) values(167,'Tunisia','TN');
+insert into country (id, countryname, countrycode) values(168,'Turkey','TR');
+insert into country (id, countryname, countrycode) values(169,'Turkmenistan','TM');
+insert into country (id, countryname, countrycode) values(170,'Uganda','UG');
+insert into country (id, countryname, countrycode) values(171,'Ukraine','UA');
+insert into country (id, countryname, countrycode) values(172,'United Arab Emirates','AE');
+insert into country (id, countryname, countrycode) values(173,'United Kiongdom','GB');
+insert into country (id, countryname, countrycode) values(174,'United States of America','US');
+insert into country (id, countryname, countrycode) values(175,'Uruguay','UY');
+insert into country (id, countryname, countrycode) values(176,'Uzbekistan','UZ');
+insert into country (id, countryname, countrycode) values(177,'Venezuela','VE');
+insert into country (id, countryname, countrycode) values(178,'Vietnam','VN');
+insert into country (id, countryname, countrycode) values(179,'Yemen','YE');
+insert into country (id, countryname, countrycode) values(180,'Yugoslavia','YU');
+insert into country (id, countryname, countrycode) values(181,'Zimbabwe','ZW');
+insert into country (id, countryname, countrycode) values(182,'Zaire','ZR');
+insert into country (id, countryname, countrycode) values(183,'Zambia','ZM');
\ No newline at end of file
diff --git a/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-xml/src/main/resources/mybatis-config.xml b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-xml/src/main/resources/mybatis-config.xml
new file mode 100644
index 000000000..75d2ec133
--- /dev/null
+++ b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-xml/src/main/resources/mybatis-config.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-xml/src/main/resources/tk/mybatis/sample/mapper/CountryMapper.xml b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-xml/src/main/resources/tk/mybatis/sample/mapper/CountryMapper.xml
new file mode 100644
index 000000000..96059b0d9
--- /dev/null
+++ b/spring-boot-starter/mapper-spring-boot-samples/mapper-spring-boot-sample-xml/src/main/resources/tk/mybatis/sample/mapper/CountryMapper.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
diff --git a/spring-boot-starter/mapper-spring-boot-samples/pom.xml b/spring-boot-starter/mapper-spring-boot-samples/pom.xml
new file mode 100644
index 000000000..8d103cdc2
--- /dev/null
+++ b/spring-boot-starter/mapper-spring-boot-samples/pom.xml
@@ -0,0 +1,61 @@
+
+
+
+
+ 4.0.0
+
+ tk.mybatis
+ mapper-spring-boot
+ 1.2.3
+
+ mapper-spring-boot-samples
+ pom
+ mapper-spring-boot-samples
+
+ mapper-spring-boot-sample-annotation
+ mapper-spring-boot-sample-xml
+
+
+
+
+ ognl
+ ognl
+ 3.1.2
+
+
+ javassist
+ javassist
+
+
+
+
+ org.javassist
+ javassist
+ 3.20.0-GA
+
+
+
+
diff --git a/spring-boot-starter/mapper-spring-boot-starter/pom.xml b/spring-boot-starter/mapper-spring-boot-starter/pom.xml
new file mode 100644
index 000000000..94c3e34e3
--- /dev/null
+++ b/spring-boot-starter/mapper-spring-boot-starter/pom.xml
@@ -0,0 +1,70 @@
+
+
+
+
+ 4.0.0
+
+ tk.mybatis
+ mapper-spring-boot
+ 1.2.3
+
+ mapper-spring-boot-starter
+ mapper-spring-boot-starter
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+ org.springframework.boot
+ spring-boot-starter-jdbc
+
+
+ org.mybatis
+ mybatis
+
+
+ org.mybatis
+ mybatis-spring
+
+
+ tk.mybatis
+ mapper-core
+
+
+ tk.mybatis
+ mapper-base
+
+
+ tk.mybatis
+ mapper-spring
+
+
+ tk.mybatis
+ mapper-spring-boot-autoconfigure
+
+
+
diff --git a/spring-boot-starter/mapper-spring-boot-starter/src/main/resources/META-INF/spring.provides b/spring-boot-starter/mapper-spring-boot-starter/src/main/resources/META-INF/spring.provides
new file mode 100644
index 000000000..b14cbe5d4
--- /dev/null
+++ b/spring-boot-starter/mapper-spring-boot-starter/src/main/resources/META-INF/spring.provides
@@ -0,0 +1 @@
+provides: mapper-spring-boot-autoconfigure,mapper,mybatis-spring-boot-autoconfigure,mybatis,mybatis-spring
diff --git a/spring-boot-starter/pom.xml b/spring-boot-starter/pom.xml
new file mode 100644
index 000000000..7da78b642
--- /dev/null
+++ b/spring-boot-starter/pom.xml
@@ -0,0 +1,128 @@
+
+
+
+
+ 4.0.0
+
+ tk.mybatis
+ mapper-parent
+ 1
+
+ mapper-spring-boot
+ 1.2.3
+ pom
+
+ mapper-spring-boot
+ Spring Boot Support for Mapper
+ https://github.com/abel533/mapper-boot-starter/
+
+
+ mapper-spring-boot-autoconfigure
+ mapper-spring-boot-starter
+ mapper-spring-boot-samples
+
+
+
+ 4.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
+ 3.4.5
+ 1.3.1
+ 1.5.9.RELEASE
+
+
+
+
+ spring-snapshots
+ http://repo.spring.io/snapshot
+
+ true
+
+
+
+ spring-milestones
+ http://repo.spring.io/milestone
+
+
+
+
+
+ spring-snapshots
+ http://repo.spring.io/snapshot
+
+
+ spring-milestones
+ http://repo.spring.io/milestone
+
+
+
+
+
+
+ tk.mybatis
+ mapper-core
+ ${mapper-core.version}
+
+
+ tk.mybatis
+ mapper-base
+ ${mapper-base.version}
+
+
+ tk.mybatis
+ mapper-spring
+ ${mapper-spring.version}
+
+
+ org.mybatis
+ mybatis
+ ${mybatis.version}
+
+
+ org.mybatis
+ mybatis-spring
+ ${mybatis-spring.version}
+
+
+ tk.mybatis
+ mapper-spring-boot-autoconfigure
+ ${project.version}
+
+
+ tk.mybatis
+ mapper-spring-boot-starter
+ ${project.version}
+
+
+ org.springframework.boot
+ spring-boot-dependencies
+ ${spring-boot.version}
+ pom
+ import
+
+
+
+
diff --git a/spring-boot-starter/properties.png b/spring-boot-starter/properties.png
new file mode 100644
index 0000000000000000000000000000000000000000..6970563d120eca655336f55275df911babd5b8d1
GIT binary patch
literal 25274
zcmc%xby!vHzWtBWB_$yZ0@6r#cXvvQgmg+vN=c`5cc*lBHv-b#Al>kt3!i7#+57B$
ze&=(Y-+x}jaxvFE?{SYYUhnx;K~5YA0T%%b3=Bz9LPQA+3<3fS44e)Q2KdT-rz<`f
z*lRFJ5kVE_+3aN|qJs6kKxJa${6e+#hz%{q<*!-yw>hKZ^JdHUit&4g$o0*Zq)
zTscF>%Z{E~aDD9(kLJr=``hHBNq4!T#tVD*!bG*ShxG&d1`YF+?=wp@tL)K1?cZHAa*h!GP@_RPeZ=P_SeTY-g__Xr4RgTi@^d8^vxlBet9R+ul{!%q>EWp|va_TMj7UoQTyUZJZSb!YL45$$me
zVxaZP{LSZMYlW6F^wHo}{vNj(cWzv_mUcIKsm%##9Y^VEcaP<_vMHyYOd3b)Lwfml
ztzOK8;WY={a_72ny;~(`ShZ`m+|TdiCmMfvTUo3B#ZQ{+>2RLweLbGGrQY)^_Ursz
zZ%RI8Tf*yk{($Y;rJ3~)_ZZ77A6?$!8ZF)i+h6a*s*9vd@}FEP|J-4Jg*YHNZvEi!
zN{;`L+4{+7$^J@zAN}X!$qmx|Hh)&d1E;IUjr(!@C^QcG^L0!5nnwI9EA~2?c6ph<
zze^gtoBm;%#@RsC=bTs{TKDm*E|K|(lUob@^b@1QCD;fb`sPyJeS_ZJNYV^$%Hh$~_p`h#I}qGw~b6R#@sJ
z#kes3VmAkN!naCs&!ufmb5gl5LsSO*efzSZ-k=Z9_=U0oT%TB5_#+r^+9v7zod{k1
zsWAJlgH#gkeM>A4*fMU6G{$2kVqB3Y!-=gDZ3lYVTA83SV$}BYM`w(#+-Uax0>$^G
zmuJHYD?|sSMwyVu71nZKfmhnT3nau~mD-BDrwAjI&d+!+3DcHcRtOVqZ)Jq%tHK?R
z8{SsPdflkEBrrm6IP)NNzZbXMJL>UL;rNWE&t)y>ymr71EL@P&!;78I4f+~|$Y39x
z{rZL;IS=6|&OJ{nOns=;0v-WY*<>uIGA}J~A*cjB
zB(ySJIW(2-39Uq;?a94jW8-{_EsN+wG}4qqONj*#JPuk;Lfy{WND*O-gLdpQ@fyn=
zCRI>;fjj%QeDcbMg=0;G!0i3Jy<=ejO9?y^RNtmN!V;|^1C$)Pb0W7*#em=A8hTyz
z&KvDvNSn7@-oe3i=}!%vt*!uExa{?xdPUnsJ;s}gi3cG9=p;BeqcLblT55_6?Gb)kO
z6{+=)UN}-2SyuDJ
z@H-Lm-jl@KeBY7X-3ZFTB9`79wjtb3Hx#Pcpyqv?jsxYpM#4CLeuLQ_
zgQ}HX*|z9!hHX~u%o-CX0lb}SycKr5v`G&dkjheVuosa(-W5)1ywh)wssUd(W~RGx
zhGE!{5EHv#@_d?Bd&32TQTBzWhc#{Mbz~)$F`0hGQEY(!f;`eGtA#5Lw=HI~`|5n)
znd`_(br!0_v{sA(ULl^s%5_%^N!)h6#LcVsSYcs({Dmlr7Ubv#dgyXBheEQVHFlI$
zYi|!Mxc!aM*VW5e(+?+SDwG!ZY3yX#f-iwjTff6LTLxIaiH6-vP2{b~Y*Frt17ggT
zp&L$Lq^>L}7cr+sM|y&1o23e)6RL3QwnB<}r_N8?r!XW7a_P0c_J$LQx_=mTz~aKX
z(YcBngvmTo&aj3;VGNnS$-95pZe;L(8B)+X)byqw4y-<6LLWybJVdoZ(i9(ixXeWp
z%l@upHi=)4DlYZt!Cz$day<3PAN`PxhKcoUWrU@<=y53ANZQBP5U{ZaH+ZD1xELbq
z>KR~*U{-W2gvg(#wZ2xY$=vsei}y
zW5HYc*w^$;j2qfS;$11rPWJdH
zj&9VPT@nW?Sdx#Dpk&;j=)SY*zhC+0EHCXsJun%zs)$$4K%w!OMBPJvE~Wf!%hGmN
zJTE~3vG($wooj=96-t)pvd&_IafYp=U>HFn6*TY2F;)A^JFQ#{JYHVw@3lSdOB8Q3
z$YzbXL;QuC2Z$Lx=8II`U4FArZnCqit7+D8Z^k_OkzFG
z)e5W?KgiwOLFLOb;hvsX+L{|gNxhHS3Pj@qXA0sQD3|05+`poBYw#|)6>GJ%72a6h{ErzUP+TV4IK7?Fo2;Xf1R4@L=SFVUL7R`!@)8D;Sx{tPKxekWv=FufxMkcTCQ(tsI1~eLXD@Ahs%)TeAT~}ZpsimqVMFA>
zQ|A2YrpCGrmS363jJ9DN)VTi}nb|}1jFI;GIdGV5=c$!txA+*WgRQLLX8=o|ezsD(
zrc)}MMw+E=AQ*mk
zvnd<$gVx!P(8ue^!fRpEh2~LdKoZTGpqcT2UBq)^8F0-nhBS#8n3;ln*xVZIhuabJ
zZhhjR;JPxIMB^`hKuqbKjO14e+HRy3IE;O5K!PtmP`u+l`O$@~v}fslaR5t7?;M$h
zitZ`P#iK|?ZAtpfd@QVUHj+i}>`Mf*b_$>>KWnG;y2C<`%{>$jzpKrLwFcF^WQS?Q
zZCbCT;g7f31{O)eiwIgvzNMg)9IcqqRl_2UIXq<2IqB1?
z(iuZ!87dvZDRE7M0;P}oe$diCVQgAQ>lW5=+9F7CaHa?EAJnxXcd!+jkWaB^J|}(=
zk>XE?_4R8|C&abmXYHFQ-!(euQa!(vw13JY@XIe+%A8tMSoDJEr4Sk)w3o?ldQtvD
zTzrG5JAg8`;+%EWaGq{T#gOKZnP#bDq{hHRO{bOI-S``3{iy>^GH`Pkvk999c6X{p
zVY;0q-rN0@s7Z`%CT1XYlYC^)|FrBsp(FTkV9^w~Sd`6`z**#NK2qoUsnd$Fn4DEq
zsc?5tE%RZ(FJJzk{zyo@1sx^hXUA+&yn)biVC}L#;$~WhVZ=**8nnYZU1I0J6)q4!fLrX7%42N)=_31XF)k=}Q*msoOZHZob2eb9M#!)Xago;ec~y`ZTDf3Ce~;oBW{D{|iEaL{m(kQybeCMW
ztwp?LO4mDK(_oFp(3~-r^Mf1_aRKevluBOIz^M)
zBgDOw5ch{~K9=^0_Qsw`NbC4-KfV`MNRoIhnlf33A2%qc4;MAamo*;L1y*Fzr!MDw
z0PVag(6DC0q)y7>RG6_wssQw@)@ghskmue@%f=op-66
z4aDyCOu+s29H(QUFC}!@E`_RyvjY4pxU-INGUB-gmjF1@UsPggx
zLLDCrlkZM^2Z19Mwm+lz?BtjGgF0ix&Le&|A}#*^!K{sZd(uARsfU$*f}gZ
za3QMe$Jq5k){j)#VRWoMPanSWoMfan$VKLit#DRNVYC7Xn+!rV2vxt4zvvfNbZ0civwCh!*=h$>D5-2i#0C;l4@c%tz^$|rYP-d
z;fS=;H0SUQ;UYeu_(mbSpPvw)$kBh4&(lwW3XpySUHOx@PJOGxr_`aZ9BF+VNe{0K
zf{=RAKT~lx*1Yx0Q7A925wFS*a2Bae^F8lJyR%J0s83mK%buy|DQ?xKUx|Kr_>Zjb
z_7PEapXt0xzm$q#e2EY#+;Bj>*RaqbDi0V#j~CG%h?ElRxHzIs=|UM3lX1nBa|=$?r-$z)&^2NG9hsc%(K-BFD~K2t^!L)00n`6p
zjL8X$@T0VMb95BD=46)E*%kd)HW^O2)~^uyxUD1lQZmJnTp8wKp~x?BmifMHft
zdXumx$9nX9y@1St?um*mWNlXp8Pbe}=!jQ)9wr08K8;hrLh$knJq5-hZ*$w$iWmB7
zB7ND3ZW{X4=Sk=f)Wi!H-Q~Q0l@AGf1HV4qf6uCc<~S1~JrhpHAMQMcTOvwm5mM-le#fxXe*JLzM1#v%ot
zkNywQxDobIy&dwOcvf3zFHrVSq$9m*?2i@C~oM5J(InO8HO5Xo+O
z%S#4{%1N4#CCLP`lGKqwn=&{cR#!VKzCcdJ^@SHAdkkH9m-8O$H@10T-_Ea|8x2joY(^G?(i=Tb6$k7{{|g
zEi8i*I`ISmh5)z=4bgv~rmI3Oe`XA8RA0pYRDYsct938in;-HOTE!^Z1i7Q7S-0tI8bOEQ%B;e^hXB$y0H#;3m%#4%tCc@MN7&fhpotm
z*g_ZdjU$d6UXH43S?}33clKY@9DF$rzrB|x?H|c!_fUNjTTV+jW?#4-UP@C~XP#W@
zbH}mzZ0y;J$h;WI++D~R_14%h{H0i>Q)VTFE?~V}Q^BOT&i_6@i^S+NyIRprc=4j)
z2XQA`h&cOa%O(Wp{7-m6Vma!i56BJdmnJb63L3Cul(A(6u(yN5anUaYaNuK~^Rp~j
z>HG3a=1+w3;*SzksmGOI-_?CWzAB7i)kDfk74~Jhw5x4LRsuKA=4E}PSM%Nd=9_%^
zxLajeAnNLQ_B0HC7^1n~hA7uF!ng7Ap?(KnS^pC;oB3aeS-)lCZ$lIk!`$$<
zX_`n@z7yN+Rlvxz0#WO+!J9dd7a--d2U+BC%}?dVRiLYn&ts`rcC5b$E&<0(%5GXH
zZ}qcVzM5H_#7lb2XyzM!*!@EX`_%S~)tdZLEPKZm@;u!mKO8*mF7%dAZZ-c$BZpR^WPK{Xhp
zjbUadR>U}w*YTjDyWZ?UaiqE>(F=;q7A|^iK8th|vfH?xht^#XVg7vtx1*BG?pEsh
z^qo4bQ%7&%_z9|qKf0%vf%)su+p^4bwcF;8xQ~}v_pSQ*cx(5bZa(psaN1^;9c^uI
zPg1{~s>I|GbY`)=*O#lj7Ad_?t>o6%`rJJFmC=n$Nmzux=${)YG&J1~H8*pNGq&?i
z2s`^q_ifHEX?XAao)z%nt#T0i?MZj8XQG-3{}M*MG))oIyhXscO};wkn^KU?`Uo92
z>G?*>(j1B+@cyy)(>1bA~6?lRk2v5>Qq=;Y^Gk#S~z
z#@bcbrBgdjqJYvkrxKAy-RX@jv~vTOTH81?!hK6ab~fiSfnaSqk}j(2E-b{{Ff&Yq
zF-5dbk0w1IVVEC2s&QoJa04-V6aOC)8hA}GgFAM)yZ-?vnewR|{8uc!dv8z;oDcNy
z($m)uEFK98SG@<