diff --git a/src/main/java/com/itfsw/mybatis/generator/plugins/ExampleTargetPlugin.java b/src/main/java/com/itfsw/mybatis/generator/plugins/ExampleTargetPlugin.java index f9fdffa..f6e6091 100644 --- a/src/main/java/com/itfsw/mybatis/generator/plugins/ExampleTargetPlugin.java +++ b/src/main/java/com/itfsw/mybatis/generator/plugins/ExampleTargetPlugin.java @@ -61,6 +61,7 @@ public class ExampleTargetPlugin extends BasePlugin { */ @Override public void initialized(IntrospectedTable introspectedTable) { + super.initialized(introspectedTable); String exampleType = introspectedTable.getExampleType(); // 修改包名 Context context = getContext(); diff --git a/src/main/java/com/itfsw/mybatis/generator/plugins/LogicalDeletePlugin.java b/src/main/java/com/itfsw/mybatis/generator/plugins/LogicalDeletePlugin.java index 470b8e0..e2c514e 100644 --- a/src/main/java/com/itfsw/mybatis/generator/plugins/LogicalDeletePlugin.java +++ b/src/main/java/com/itfsw/mybatis/generator/plugins/LogicalDeletePlugin.java @@ -75,6 +75,7 @@ public class LogicalDeletePlugin extends BasePlugin { */ @Override public void initialized(IntrospectedTable introspectedTable) { + super.initialized(introspectedTable); // 1. 首先获取全局配置 Properties properties = getProperties(); String logicalDeleteColumn = properties.getProperty(PRO_LOGICAL_DELETE_COLUMN); diff --git a/src/main/java/com/itfsw/mybatis/generator/plugins/OptimisticLockerPlugin.java b/src/main/java/com/itfsw/mybatis/generator/plugins/OptimisticLockerPlugin.java index 3a07580..9ffed0c 100644 --- a/src/main/java/com/itfsw/mybatis/generator/plugins/OptimisticLockerPlugin.java +++ b/src/main/java/com/itfsw/mybatis/generator/plugins/OptimisticLockerPlugin.java @@ -59,6 +59,7 @@ public class OptimisticLockerPlugin extends BasePlugin implements IModelBuilderP @Override public void initialized(IntrospectedTable introspectedTable) { + super.initialized(introspectedTable); sqlMaps.put(introspectedTable, new ArrayList<>()); // 读取并验证版本列 diff --git a/src/main/java/com/itfsw/mybatis/generator/plugins/TableConfigurationPlugin.java b/src/main/java/com/itfsw/mybatis/generator/plugins/TableConfigurationPlugin.java new file mode 100644 index 0000000..1ef04bd --- /dev/null +++ b/src/main/java/com/itfsw/mybatis/generator/plugins/TableConfigurationPlugin.java @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2018. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.itfsw.mybatis.generator.plugins; + +import com.itfsw.mybatis.generator.plugins.utils.BasePlugin; +import com.itfsw.mybatis.generator.plugins.utils.BeanUtils; +import com.itfsw.mybatis.generator.plugins.utils.hook.ITableConfigurationHook; +import org.mybatis.generator.api.FullyQualifiedTable; +import org.mybatis.generator.api.IntrospectedTable; +import org.mybatis.generator.config.ColumnRenamingRule; +import org.mybatis.generator.config.DomainObjectRenamingRule; +import org.mybatis.generator.config.TableConfiguration; + +import java.util.List; +import java.util.Properties; + +import static org.mybatis.generator.internal.util.StringUtility.stringHasValue; + +/** + * --------------------------------------------------------------------------- + * + * --------------------------------------------------------------------------- + * @author: hewei + * @time:2018/5/21 11:23 + * --------------------------------------------------------------------------- + */ +public class TableConfigurationPlugin extends BasePlugin implements ITableConfigurationHook { + public static final String PRO_TABLE_SEARCH_STRING = "domainObjectRenamingRule.searchString"; // 查找 property + public static final String PRO_TABLE_REPLACE_STRING = "domainObjectRenamingRule.replaceString"; // 替换 property + public static final String PRO_COLUMN_SEARCH_STRING = "columnRenamingRule.searchString"; // 查找 property + public static final String PRO_COLUMN_REPLACE_STRING = "columnRenamingRule.replaceString"; // 替换 property + + public static final String PRO_CLIENT_SUFFIX = "clientSuffix"; // client 结尾 + public static final String PRO_SQL_MAP_SUFFIX = "sqlMapSuffix"; // sqlMap 结尾 + public static final String PRO_EXAMPLE_SUFFIX = "exampleSuffix"; // example 结尾 + public static final String PRO_MODEL_SUFFIX = "modelSuffix"; // model 结尾 + + private String tableSearchString; + private String tableReplaceString; + private String columnSearchString; + private String columnReplaceString; + + private String clientSuffix; // client 结尾 + private String sqlMapSuffix; // sqlMap 结尾 + private String exampleSuffix; // example 结尾 + private String modelSuffix; // model 结尾 + + /** + * {@inheritDoc} + * @param warnings + * @return + */ + @Override + public boolean validate(List warnings) { + Properties properties = this.getProperties(); + // 如果配置了searchString 或者 replaceString,二者不允许单独存在 + if ((properties.getProperty(PRO_TABLE_SEARCH_STRING) == null && properties.getProperty(PRO_TABLE_REPLACE_STRING) != null) + || (properties.getProperty(PRO_TABLE_SEARCH_STRING) != null && properties.getProperty(PRO_TABLE_REPLACE_STRING) == null) + || (properties.getProperty(PRO_COLUMN_SEARCH_STRING) == null && properties.getProperty(PRO_COLUMN_REPLACE_STRING) != null) + || (properties.getProperty(PRO_COLUMN_SEARCH_STRING) != null && properties.getProperty(PRO_COLUMN_REPLACE_STRING) == null)) { + warnings.add("itfsw:插件" + this.getClass().getTypeName() + "插件的searchString、replaceString属性需配合使用,不能单独存在!"); + return false; + } + + this.tableSearchString = properties.getProperty(PRO_TABLE_SEARCH_STRING); + this.tableReplaceString = properties.getProperty(PRO_TABLE_REPLACE_STRING); + this.columnSearchString = properties.getProperty(PRO_COLUMN_SEARCH_STRING); + this.columnReplaceString = properties.getProperty(PRO_COLUMN_REPLACE_STRING); + this.exampleSuffix = properties.getProperty(PRO_EXAMPLE_SUFFIX); + this.clientSuffix = properties.getProperty(PRO_CLIENT_SUFFIX); + this.sqlMapSuffix = properties.getProperty(PRO_SQL_MAP_SUFFIX); + this.modelSuffix = properties.getProperty(PRO_MODEL_SUFFIX); + + return super.validate(warnings); + } + + /** + * 表配置 + * @param introspectedTable + */ + @Override + public void tableConfiguration(IntrospectedTable introspectedTable) { + try { + TableConfiguration tableConfiguration = introspectedTable.getTableConfiguration(); + FullyQualifiedTable fullyQualifiedTable = introspectedTable.getFullyQualifiedTable(); + + String javaClientInterfacePackage = (String) BeanUtils.invoke(introspectedTable, IntrospectedTable.class, "calculateJavaClientInterfacePackage"); + String sqlMapPackage = (String) BeanUtils.invoke(introspectedTable, IntrospectedTable.class, "calculateSqlMapPackage"); + String javaModelPackage = (String) BeanUtils.invoke(introspectedTable, IntrospectedTable.class, "calculateJavaModelPackage"); + // --------------------- table 重命名 ---------------------------- + if (tableConfiguration.getDomainObjectRenamingRule() == null + && this.tableSearchString != null && this.tableReplaceString != null) { + DomainObjectRenamingRule rule = new DomainObjectRenamingRule(); + rule.setSearchString(this.tableSearchString); + rule.setReplaceString(this.tableReplaceString); + tableConfiguration.setDomainObjectRenamingRule(rule); + } + // --------------------- column 重命名 --------------------------- + if (tableConfiguration.getColumnRenamingRule() == null + && this.columnSearchString != null && this.columnReplaceString != null) { + ColumnRenamingRule rule = new ColumnRenamingRule(); + rule.setSearchString(this.columnSearchString); + rule.setReplaceString(this.columnReplaceString); + tableConfiguration.setColumnRenamingRule(rule); + } + + // ---------------------- 后缀修正 ------------------------------- + // 1. client + if (this.clientSuffix != null) { + // mapper + StringBuilder sb = new StringBuilder(); + sb.append(javaClientInterfacePackage); + sb.append('.'); + if (stringHasValue(tableConfiguration.getMapperName())) { + sb.append(tableConfiguration.getMapperName()); + } else { + if (stringHasValue(fullyQualifiedTable.getDomainObjectSubPackage())) { + sb.append(fullyQualifiedTable.getDomainObjectSubPackage()); + sb.append('.'); + } + sb.append(fullyQualifiedTable.getDomainObjectName()); + sb.append(this.clientSuffix); + } + introspectedTable.setMyBatis3JavaMapperType(sb.toString()); + // xml mapper namespace + sb.setLength(0); + sb.append(sqlMapPackage); + sb.append('.'); + if (stringHasValue(tableConfiguration.getMapperName())) { + sb.append(tableConfiguration.getMapperName()); + } else { + sb.append(fullyQualifiedTable.getDomainObjectName()); + sb.append(this.clientSuffix); + } + introspectedTable.setMyBatis3FallbackSqlMapNamespace(sb.toString()); + } + // 2. sqlMap + if (!stringHasValue(tableConfiguration.getMapperName()) + && (this.sqlMapSuffix != null || this.clientSuffix != null)) { + StringBuilder sb = new StringBuilder(); + + sb.append(fullyQualifiedTable.getDomainObjectName()); + sb.append(this.sqlMapSuffix != null ? this.sqlMapSuffix : this.clientSuffix); + sb.append(".xml"); + + introspectedTable.setMyBatis3XmlMapperFileName(sb.toString()); + } + + // 2. example + if (this.exampleSuffix != null) { + StringBuilder sb = new StringBuilder(); + sb.append(javaModelPackage); + sb.append('.'); + sb.append(fullyQualifiedTable.getDomainObjectName()); + sb.append(this.exampleSuffix); + introspectedTable.setExampleType(sb.toString()); + } + // 3. model + if (this.modelSuffix != null) { + StringBuilder sb = new StringBuilder(); + sb.append(javaModelPackage); + sb.append('.'); + sb.append(fullyQualifiedTable.getDomainObjectName()); + sb.append("Key"); + sb.append(this.modelSuffix); + introspectedTable.setPrimaryKeyType(sb.toString()); + + sb.setLength(0); + sb.append(javaModelPackage); + sb.append('.'); + sb.append(fullyQualifiedTable.getDomainObjectName()); + sb.append(this.modelSuffix); + introspectedTable.setBaseRecordType(sb.toString()); + + sb.setLength(0); + sb.append(javaModelPackage); + sb.append('.'); + sb.append(fullyQualifiedTable.getDomainObjectName()); + sb.append("WithBLOBs"); + sb.append(this.modelSuffix); + introspectedTable.setRecordWithBLOBsType(sb.toString()); + } + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/itfsw/mybatis/generator/plugins/TablePrefixPlugin.java b/src/main/java/com/itfsw/mybatis/generator/plugins/TablePrefixPlugin.java index 299dab6..8349d82 100644 --- a/src/main/java/com/itfsw/mybatis/generator/plugins/TablePrefixPlugin.java +++ b/src/main/java/com/itfsw/mybatis/generator/plugins/TablePrefixPlugin.java @@ -31,6 +31,7 @@ import java.util.List; * @time:2017/5/18 13:54 * --------------------------------------------------------------------------- */ +@Deprecated public class TablePrefixPlugin extends BasePlugin { public static final String PRO_PREFIX = "prefix"; // 前缀 property @@ -78,5 +79,6 @@ public class TablePrefixPlugin extends BasePlugin { logger.error("itfsw:插件" + this.getClass().getTypeName() + "使用prefix替换时异常!", e); } } + super.initialized(introspectedTable); } } diff --git a/src/main/java/com/itfsw/mybatis/generator/plugins/TableRenamePlugin.java b/src/main/java/com/itfsw/mybatis/generator/plugins/TableRenamePlugin.java index 8039345..39c10b1 100644 --- a/src/main/java/com/itfsw/mybatis/generator/plugins/TableRenamePlugin.java +++ b/src/main/java/com/itfsw/mybatis/generator/plugins/TableRenamePlugin.java @@ -33,6 +33,7 @@ import java.util.regex.Pattern; * @time:2017/6/6 15:18 * --------------------------------------------------------------------------- */ +@Deprecated public class TableRenamePlugin extends BasePlugin { public static final String PRO_SEARCH_STRING = "searchString"; // 查找 property public static final String PRO_REPLACE_STRING = "replaceString"; // 替换 property @@ -94,6 +95,7 @@ public class TableRenamePlugin extends BasePlugin { logger.error("itfsw:插件" + this.getClass().getTypeName() + "使用searchString、replaceString替换时异常!", e); } } + super.initialized(introspectedTable); } /** diff --git a/src/main/java/com/itfsw/mybatis/generator/plugins/utils/BasePlugin.java b/src/main/java/com/itfsw/mybatis/generator/plugins/utils/BasePlugin.java index 6605801..117c959 100644 --- a/src/main/java/com/itfsw/mybatis/generator/plugins/utils/BasePlugin.java +++ b/src/main/java/com/itfsw/mybatis/generator/plugins/utils/BasePlugin.java @@ -19,7 +19,9 @@ package com.itfsw.mybatis.generator.plugins.utils; import com.itfsw.mybatis.generator.plugins.CommentPlugin; import com.itfsw.mybatis.generator.plugins.utils.enhanced.TemplateCommentGenerator; import com.itfsw.mybatis.generator.plugins.utils.hook.HookAggregator; +import com.itfsw.mybatis.generator.plugins.utils.hook.ITableConfigurationHook; import org.mybatis.generator.api.CommentGenerator; +import org.mybatis.generator.api.IntrospectedTable; import org.mybatis.generator.api.PluginAdapter; import org.mybatis.generator.config.Context; import org.mybatis.generator.config.PluginConfiguration; @@ -97,4 +99,14 @@ public class BasePlugin extends PluginAdapter { return true; } + + /** + * {@inheritDoc} + * @param introspectedTable + */ + @Override + public void initialized(IntrospectedTable introspectedTable) { + super.initialized(introspectedTable); + PluginTools.getHook(ITableConfigurationHook.class).tableConfiguration(introspectedTable); + } } diff --git a/src/main/java/com/itfsw/mybatis/generator/plugins/utils/BeanUtils.java b/src/main/java/com/itfsw/mybatis/generator/plugins/utils/BeanUtils.java index f5138bd..b7c39ba 100644 --- a/src/main/java/com/itfsw/mybatis/generator/plugins/utils/BeanUtils.java +++ b/src/main/java/com/itfsw/mybatis/generator/plugins/utils/BeanUtils.java @@ -58,14 +58,15 @@ public class BeanUtils { /** * 执行无参方法 * @param bean + * @param clazz * @param name * @return * @throws NoSuchMethodException * @throws InvocationTargetException * @throws IllegalAccessException */ - public static Object invoke(final Object bean, final String name) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { - Method method = bean.getClass().getDeclaredMethod(name); + public static Object invoke(final Object bean, Class clazz, final String name) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + Method method = clazz.getDeclaredMethod(name); method.setAccessible(true); return method.invoke(bean); } diff --git a/src/main/java/com/itfsw/mybatis/generator/plugins/utils/hook/HookAggregator.java b/src/main/java/com/itfsw/mybatis/generator/plugins/utils/hook/HookAggregator.java index e5592a6..59f609e 100644 --- a/src/main/java/com/itfsw/mybatis/generator/plugins/utils/hook/HookAggregator.java +++ b/src/main/java/com/itfsw/mybatis/generator/plugins/utils/hook/HookAggregator.java @@ -43,7 +43,7 @@ import java.util.List; * @time:2018/4/27 11:33 * --------------------------------------------------------------------------- */ -public class HookAggregator implements IUpsertPluginHook, IModelBuilderPluginHook, IIncrementsPluginHook, IOptimisticLockerPluginHook, ISelectOneByExamplePluginHook { +public class HookAggregator implements IUpsertPluginHook, IModelBuilderPluginHook, IIncrementsPluginHook, IOptimisticLockerPluginHook, ISelectOneByExamplePluginHook, ITableConfigurationHook { protected static final Logger logger = LoggerFactory.getLogger(BasePlugin.class); // 日志 private final static HookAggregator instance = new HookAggregator(); private Context context; @@ -250,4 +250,13 @@ public class HookAggregator implements IUpsertPluginHook, IModelBuilderPluginHoo } return true; } + + // ============================================= ITableConfigurationHook ============================================== + + @Override + public void tableConfiguration(IntrospectedTable introspectedTable) { + if (!this.getPlugins(ITableConfigurationHook.class).isEmpty()) { + this.getPlugins(ITableConfigurationHook.class).get(0).tableConfiguration(introspectedTable); + } + } } diff --git a/src/main/java/com/itfsw/mybatis/generator/plugins/utils/hook/ITableConfigurationHook.java b/src/main/java/com/itfsw/mybatis/generator/plugins/utils/hook/ITableConfigurationHook.java new file mode 100644 index 0000000..0faf1a9 --- /dev/null +++ b/src/main/java/com/itfsw/mybatis/generator/plugins/utils/hook/ITableConfigurationHook.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2018. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.itfsw.mybatis.generator.plugins.utils.hook; + +import org.mybatis.generator.api.IntrospectedTable; + +/** + * --------------------------------------------------------------------------- + * + * --------------------------------------------------------------------------- + * @author: hewei + * @time:2018/5/21 11:24 + * --------------------------------------------------------------------------- + */ +public interface ITableConfigurationHook { + /** + * 表配置 + * @param introspectedTable + */ + void tableConfiguration(IntrospectedTable introspectedTable); +} diff --git a/src/test/java/com/itfsw/mybatis/generator/plugins/TableConfigurationPluginTest.java b/src/test/java/com/itfsw/mybatis/generator/plugins/TableConfigurationPluginTest.java new file mode 100644 index 0000000..2473790 --- /dev/null +++ b/src/test/java/com/itfsw/mybatis/generator/plugins/TableConfigurationPluginTest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2018. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.itfsw.mybatis.generator.plugins; + +import com.itfsw.mybatis.generator.plugins.tools.AbstractShellCallback; +import com.itfsw.mybatis.generator.plugins.tools.DBHelper; +import com.itfsw.mybatis.generator.plugins.tools.MyBatisGeneratorTool; +import org.apache.ibatis.session.SqlSession; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * --------------------------------------------------------------------------- + * + * --------------------------------------------------------------------------- + * @author: hewei + * @time:2018/5/22 13:22 + * --------------------------------------------------------------------------- + */ +public class TableConfigurationPluginTest { + @BeforeClass + public static void init() throws Exception { + DBHelper.createDB("scripts/TableConfigurationPlugin/init.sql"); + } + + @Test + public void test() throws Exception { + MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/TableConfigurationPlugin/mybatis-generator.xml"); + tool.generate(() -> DBHelper.resetDB("scripts/TableConfigurationPlugin/init.sql"), new AbstractShellCallback() { + @Override + public void reloadProject(SqlSession sqlSession, ClassLoader loader, String packagz) throws Exception { + + } + }); + } +} \ No newline at end of file diff --git a/src/test/resources/scripts/TableConfigurationPlugin/init.sql b/src/test/resources/scripts/TableConfigurationPlugin/init.sql new file mode 100644 index 0000000..7dff5d3 --- /dev/null +++ b/src/test/resources/scripts/TableConfigurationPlugin/init.sql @@ -0,0 +1,120 @@ +/* +Navicat MySQL Data Transfer + +Source Server : localhost +Source Server Version : 50617 +Source Host : localhost:3306 +Source Database : mybatis-generator-plugin + +Target Server Type : MYSQL +Target Server Version : 50617 +File Encoding : 65001 + +Date: 2017-07-05 17:21:41 +*/ + +SET FOREIGN_KEY_CHECKS=0; + +-- ---------------------------- +-- Table structure for tb +-- ---------------------------- +DROP TABLE IF EXISTS `tb`; +CREATE TABLE `tb` ( + `id` bigint(20) NOT NULL COMMENT '注释1', + `field1` varchar(255) DEFAULT NULL COMMENT '注释2', + `inc_f1` bigint(20) NOT NULL DEFAULT '0', + `inc_f2` bigint(20) DEFAULT '0', + `inc_f3` bigint(20) DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Records of tb +-- ---------------------------- +INSERT INTO `tb` VALUES ('1', 'fd1', '0', '0', '0'); +INSERT INTO `tb` VALUES ('2', 'fd2', '1', '2', '3'); +INSERT INTO `tb` VALUES ('3', null, '3', '2', '1'); +INSERT INTO `tb` VALUES ('4', 'fd3', '1', '1', '1'); + +-- ---------------------------- +-- Table structure for tb_blobs +-- ---------------------------- +DROP TABLE IF EXISTS `tb_blobs`; +CREATE TABLE `tb_blobs` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '注释1', + `field1` varchar(255) DEFAULT NULL, + `field2` longtext COMMENT '注释2', + `field3` longtext, + `inc_f1` bigint(20) NOT NULL DEFAULT '0', + `inc_f2` bigint(20) NOT NULL DEFAULT '0', + `inc_f3` bigint(20) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Records of tb_blobs +-- ---------------------------- +INSERT INTO `tb_blobs` VALUES ('1', 'fd1', null, null, '1', '2', '3'); +INSERT INTO `tb_blobs` VALUES ('2', null, 'fd2', null, '3', '2', '1'); +INSERT INTO `tb_blobs` VALUES ('3', null, null, 'fd3', '1', '1', '1'); +INSERT INTO `tb_blobs` VALUES ('4', 'fd4', 'fd5', 'fd6', '0', '0', '0'); + +-- ---------------------------- +-- Table structure for tb_keys +-- ---------------------------- +DROP TABLE IF EXISTS `tb_keys`; +CREATE TABLE `tb_keys` ( + `key1` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '注释1', + `key2` varchar(255) NOT NULL, + `field1` varchar(255) DEFAULT NULL COMMENT '注释2', + `field2` int(11) DEFAULT NULL, + `inc_f1` bigint(20) NOT NULL DEFAULT '0', + `inc_f2` bigint(20) NOT NULL DEFAULT '0', + `inc_f3` bigint(20) NOT NULL DEFAULT '0', + PRIMARY KEY (`key1`,`key2`) +) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Records of tb_keys +-- ---------------------------- +INSERT INTO `tb_keys` VALUES ('1', 'k1', 'fd1', null, '1', '2', '3'); +INSERT INTO `tb_keys` VALUES ('2', 'k2', null, '2', '3', '2', '1'); +INSERT INTO `tb_keys` VALUES ('3', 'k3', null, null, '1', '1', '1'); + +-- ---------------------------- +-- Table structure for tb_single_blob +-- ---------------------------- +DROP TABLE IF EXISTS `tb_single_blob`; +CREATE TABLE `tb_single_blob` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '注释1', + `field1` longtext COMMENT '注释2', + `field2` int(11) DEFAULT NULL, + `inc_f1` bigint(20) NOT NULL DEFAULT '0', + `inc_f2` bigint(20) NOT NULL DEFAULT '0', + `inc_f3` bigint(20) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Records of tb_single_blob +-- ---------------------------- +INSERT INTO `tb_single_blob` VALUES ('1', 'fd1', '0', '1', '2', '3'); +INSERT INTO `tb_single_blob` VALUES ('2', null, null, '3', '2', '1'); +INSERT INTO `tb_single_blob` VALUES ('3', null, null, '1', '1', '1'); + +-- ---------------------------- +-- Table structure for tb_key_word +-- ---------------------------- +DROP TABLE IF EXISTS `tb_key_word`; +CREATE TABLE `tb_key_word` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '注释1', + `field2` int(11) DEFAULT NULL, + `inc_f1` bigint(20) NOT NULL DEFAULT '0', + `update` bigint(20) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Records of tb_key_word +-- ---------------------------- +INSERT INTO `tb_key_word` VALUES ('1', '0', '0', '1'); \ No newline at end of file diff --git a/src/test/resources/scripts/TableConfigurationPlugin/mybatis-generator.xml b/src/test/resources/scripts/TableConfigurationPlugin/mybatis-generator.xml new file mode 100644 index 0000000..8421164 --- /dev/null +++ b/src/test/resources/scripts/TableConfigurationPlugin/mybatis-generator.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+
+
\ No newline at end of file