diff --git a/src/main/java/com/itfsw/mybatis/generator/plugins/ExampleEnhancedPlugin.java b/src/main/java/com/itfsw/mybatis/generator/plugins/ExampleEnhancedPlugin.java index 14f28d8..8692d44 100644 --- a/src/main/java/com/itfsw/mybatis/generator/plugins/ExampleEnhancedPlugin.java +++ b/src/main/java/com/itfsw/mybatis/generator/plugins/ExampleEnhancedPlugin.java @@ -13,8 +13,6 @@ import org.mybatis.generator.codegen.mybatis3.MyBatis3FormattingUtilities; import java.util.List; -import static org.mybatis.generator.internal.util.StringUtility.stringHasValue; - /** * --------------------------------------------------------------------------- * Example 增强插件 @@ -130,14 +128,7 @@ public class ExampleEnhancedPlugin extends BasePlugin { // 方法体 sb.setLength(0); - if (stringHasValue(introspectedColumn.getTypeHandler())) { - sb.append("add"); - sb.append(introspectedColumn.getJavaProperty()); - sb.setCharAt(3, Character.toUpperCase(sb.charAt(3))); - sb.append("Criterion("); - } else { - sb.append("addCriterion("); - } + sb.append("addCriterion("); sb.append("new StringBuilder(\""); sb.append(MyBatis3FormattingUtilities.getAliasedActualColumnName(introspectedColumn)); sb.append(" "); diff --git a/src/test/java/com/itfsw/mybatis/generator/plugins/BugFixedTest.java b/src/test/java/com/itfsw/mybatis/generator/plugins/BugFixedTest.java index b222670..b6024d1 100644 --- a/src/test/java/com/itfsw/mybatis/generator/plugins/BugFixedTest.java +++ b/src/test/java/com/itfsw/mybatis/generator/plugins/BugFixedTest.java @@ -108,6 +108,21 @@ public class BugFixedTest { }); } + /** + * typeHandler 导致的问题 + */ + @Test + public void issues36() throws Exception { + MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/BugFixedTest/issues-36.xml"); + tool.generate(() -> DBHelper.createDB("scripts/BugFixedTest/issues-36.sql"), new AbstractShellCallback() { + @Override + public void reloadProject(SqlSession sqlSession, ClassLoader loader, String packagz) throws Exception { + // Example 编译报错 + new ObjectUtil(loader, packagz + ".TbExample"); + } + }); + } + /** * 乐观锁插件好像变量作用域问题导致,前一个表的配置会影响后一个表配置 */ diff --git a/src/test/resources/scripts/BugFixedTest/issues-36.sql b/src/test/resources/scripts/BugFixedTest/issues-36.sql new file mode 100644 index 0000000..254a1ad --- /dev/null +++ b/src/test/resources/scripts/BugFixedTest/issues-36.sql @@ -0,0 +1,27 @@ +/* +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-06-27 11:17:08 +*/ + +SET FOREIGN_KEY_CHECKS=0; + +-- ---------------------------- +-- Table structure for tb +-- ---------------------------- +DROP TABLE IF EXISTS `tb`; +CREATE TABLE `tb` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '注释1', + `field1` varchar(255) DEFAULT NULL COMMENT '注释2', + `t_date` date DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; \ No newline at end of file diff --git a/src/test/resources/scripts/BugFixedTest/issues-36.xml b/src/test/resources/scripts/BugFixedTest/issues-36.xml new file mode 100644 index 0000000..46f7b3d --- /dev/null +++ b/src/test/resources/scripts/BugFixedTest/issues-36.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
\ No newline at end of file