diff --git a/src/main/java/com/itfsw/mybatis/generator/plugins/LombokPlugin.java b/src/main/java/com/itfsw/mybatis/generator/plugins/LombokPlugin.java
index 0ca1dd4..1ea1811 100644
--- a/src/main/java/com/itfsw/mybatis/generator/plugins/LombokPlugin.java
+++ b/src/main/java/com/itfsw/mybatis/generator/plugins/LombokPlugin.java
@@ -73,21 +73,26 @@ public class LombokPlugin extends BasePlugin {
public boolean modelBaseRecordClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
// @Data
this.addAnnotations(topLevelClass, EnumLombokAnnotations.DATA);
- if (topLevelClass.getSuperClass() != null){
+ if (topLevelClass.getSuperClass() != null) {
this.addAnnotations(topLevelClass, EnumLombokAnnotations.EQUALS_AND_HASH_CODE_CALL_SUPER);
+ this.addAnnotations(topLevelClass, EnumLombokAnnotations.TO_STRING_CALL_SUPER);
}
+
// @Builder
- if (this.hasBuilder){
- if (introspectedTable.getRules().generateRecordWithBLOBsClass() || introspectedTable.getRules().generatePrimaryKeyClass()){
+ if (this.hasBuilder) {
+ // 有子类或者父类
+ if (introspectedTable.getRules().generateRecordWithBLOBsClass() || introspectedTable.getRules().generatePrimaryKeyClass() || topLevelClass.getSuperClass() != null) {
this.addAnnotations(topLevelClass, EnumLombokAnnotations.SUPER_BUILDER);
} else {
this.addAnnotations(topLevelClass, EnumLombokAnnotations.BUILDER);
}
}
- if (this.hasNoArgsConstructor){
+
+ // @Constructor
+ if (this.hasNoArgsConstructor) {
this.addAnnotations(topLevelClass, EnumLombokAnnotations.NO_ARGS_CONSTRUCTOR);
}
- if (this.hasAllArgsConstructor){
+ if (this.hasAllArgsConstructor) {
this.addAnnotations(topLevelClass, EnumLombokAnnotations.ALL_ARGS_CONSTRUCTOR);
}
return super.modelBaseRecordClassGenerated(topLevelClass, introspectedTable);
@@ -103,19 +108,26 @@ public class LombokPlugin extends BasePlugin {
public boolean modelPrimaryKeyClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
// @Data
this.addAnnotations(topLevelClass, EnumLombokAnnotations.DATA);
+ if (topLevelClass.getSuperClass() != null) {
+ this.addAnnotations(topLevelClass, EnumLombokAnnotations.EQUALS_AND_HASH_CODE_CALL_SUPER);
+ this.addAnnotations(topLevelClass, EnumLombokAnnotations.TO_STRING_CALL_SUPER);
+ }
// @Builder
- if (this.hasBuilder){
- if (introspectedTable.getRules().generateRecordWithBLOBsClass() || introspectedTable.getRules().generateBaseRecordClass()){
+ if (this.hasBuilder) {
+ // 有子类或者父类
+ if (introspectedTable.getRules().generateRecordWithBLOBsClass() || introspectedTable.getRules().generateBaseRecordClass() || topLevelClass.getSuperClass() != null) {
this.addAnnotations(topLevelClass, EnumLombokAnnotations.SUPER_BUILDER);
} else {
this.addAnnotations(topLevelClass, EnumLombokAnnotations.BUILDER);
}
}
- if (this.hasNoArgsConstructor){
+
+ // @Constructor
+ if (this.hasNoArgsConstructor) {
this.addAnnotations(topLevelClass, EnumLombokAnnotations.NO_ARGS_CONSTRUCTOR);
}
- if (this.hasAllArgsConstructor){
+ if (this.hasAllArgsConstructor) {
this.addAnnotations(topLevelClass, EnumLombokAnnotations.ALL_ARGS_CONSTRUCTOR);
}
return super.modelPrimaryKeyClassGenerated(topLevelClass, introspectedTable);
@@ -131,22 +143,26 @@ public class LombokPlugin extends BasePlugin {
public boolean modelRecordWithBLOBsClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
// @Data
this.addAnnotations(topLevelClass, EnumLombokAnnotations.DATA);
- if (topLevelClass.getSuperClass() != null){
+ if (topLevelClass.getSuperClass() != null) {
this.addAnnotations(topLevelClass, EnumLombokAnnotations.EQUALS_AND_HASH_CODE_CALL_SUPER);
+ this.addAnnotations(topLevelClass, EnumLombokAnnotations.TO_STRING_CALL_SUPER);
}
// @Builder
- if (this.hasBuilder){
- if (introspectedTable.getRules().generateBaseRecordClass() || introspectedTable.getRules().generatePrimaryKeyClass()){
+ if (this.hasBuilder) {
+ // 有子类或者父类
+ if (introspectedTable.getRules().generateBaseRecordClass() || introspectedTable.getRules().generatePrimaryKeyClass() || topLevelClass.getSuperClass() != null) {
this.addAnnotations(topLevelClass, EnumLombokAnnotations.SUPER_BUILDER);
} else {
this.addAnnotations(topLevelClass, EnumLombokAnnotations.BUILDER);
}
}
- if (this.hasNoArgsConstructor){
+
+ // @Constructor
+ if (this.hasNoArgsConstructor) {
this.addAnnotations(topLevelClass, EnumLombokAnnotations.NO_ARGS_CONSTRUCTOR);
}
- if (this.hasAllArgsConstructor){
+ if (this.hasAllArgsConstructor) {
this.addAnnotations(topLevelClass, EnumLombokAnnotations.ALL_ARGS_CONSTRUCTOR);
}
return super.modelRecordWithBLOBsClassGenerated(topLevelClass, introspectedTable);
@@ -185,28 +201,47 @@ public class LombokPlugin extends BasePlugin {
* @param topLevelClass
* @param annotations
*/
- private void addAnnotations(TopLevelClass topLevelClass, EnumLombokAnnotations annotations){
- topLevelClass.addImportedType(annotations.clazz);
- topLevelClass.addAnnotation(annotations.annotations);
+ private void addAnnotations(TopLevelClass topLevelClass, EnumLombokAnnotations annotations) {
+ topLevelClass.addImportedType(annotations.getClazz());
+ topLevelClass.addAnnotation(annotations.getAnnotation());
}
/**
* lombok 类型
*/
- public static enum EnumLombokAnnotations {
+ public enum EnumLombokAnnotations {
DATA("@Data", "lombok.Data"),
BUILDER("@Builder", "lombok.Builder"),
SUPER_BUILDER("@SuperBuilder", "lombok.experimental.SuperBuilder"),
ALL_ARGS_CONSTRUCTOR("@AllArgsConstructor", "lombok.AllArgsConstructor"),
+ NO_ARGS_CONSTRUCTOR("@NoArgsConstructor", "lombok.NoArgsConstructor"),
EQUALS_AND_HASH_CODE_CALL_SUPER("@EqualsAndHashCode(callSuper = true)", "lombok.EqualsAndHashCode"),
- NO_ARGS_CONSTRUCTOR("@NoArgsConstructor", "lombok.NoArgsConstructor");
+ TO_STRING_CALL_SUPER("@ToString(callSuper = true)", "lombok.ToString");
- private final String annotations;
+ private final String annotation;
private final String clazz;
- EnumLombokAnnotations(String annotations, String clazz) {
- this.annotations = annotations;
+ EnumLombokAnnotations(String annotation, String clazz) {
+ this.annotation = annotation;
this.clazz = clazz;
}
+
+ /**
+ * Getter method for property annotation.
+ * @return property value of annotation
+ * @author hewei
+ */
+ public String getAnnotation() {
+ return annotation;
+ }
+
+ /**
+ * Getter method for property clazz.
+ * @return property value of clazz
+ * @author hewei
+ */
+ public String getClazz() {
+ return clazz;
+ }
}
}
diff --git a/src/test/java/com/itfsw/mybatis/generator/plugins/LombokPluginTest.java b/src/test/java/com/itfsw/mybatis/generator/plugins/LombokPluginTest.java
index 6aada13..14b578a 100644
--- a/src/test/java/com/itfsw/mybatis/generator/plugins/LombokPluginTest.java
+++ b/src/test/java/com/itfsw/mybatis/generator/plugins/LombokPluginTest.java
@@ -19,11 +19,20 @@ 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 com.itfsw.mybatis.generator.plugins.tools.ObjectUtil;
import org.apache.ibatis.session.SqlSession;
+import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.mybatis.generator.api.GeneratedJavaFile;
import org.mybatis.generator.api.MyBatisGenerator;
+import org.mybatis.generator.api.dom.java.CompilationUnit;
+import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
+
+import java.lang.reflect.Constructor;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
/**
* ---------------------------------------------------------------------------
@@ -38,7 +47,7 @@ public class LombokPluginTest {
* 初始化
*/
@BeforeClass
- public static void init() throws Exception{
+ public static void init() throws Exception {
DBHelper.createDB("scripts/LombokPlugin/init.sql");
}
@@ -47,22 +56,261 @@ public class LombokPluginTest {
*/
@Test
public void testGenerate() throws Exception {
- // 全局规则增加 DB, tb2 单独规则增加Tt
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/LombokPlugin/mybatis-generator.xml");
MyBatisGenerator myBatisGenerator = tool.generate();
- for (GeneratedJavaFile file : myBatisGenerator.getGeneratedJavaFiles()){
- String name = file.getCompilationUnit().getType().getShortName();
+ for (GeneratedJavaFile file : myBatisGenerator.getGeneratedJavaFiles()) {
+ CompilationUnit compilationUnit = file.getCompilationUnit();
+ String name = compilationUnit.getType().getShortName();
+ if ("TbKeyBlobKey".equals(name)) {
+ Assert.assertTrue(checkImportedType(compilationUnit.getImportedTypes(), Arrays.asList(
+ LombokPlugin.EnumLombokAnnotations.DATA,
+ LombokPlugin.EnumLombokAnnotations.SUPER_BUILDER,
+ LombokPlugin.EnumLombokAnnotations.NO_ARGS_CONSTRUCTOR,
+ LombokPlugin.EnumLombokAnnotations.ALL_ARGS_CONSTRUCTOR
+ ), true));
+
+ Assert.assertFalse(checkImportedType(compilationUnit.getImportedTypes(), Arrays.asList(
+ LombokPlugin.EnumLombokAnnotations.BUILDER,
+ LombokPlugin.EnumLombokAnnotations.EQUALS_AND_HASH_CODE_CALL_SUPER
+ ), false));
+ } else if ("TbKeyBlobWithBLOBs".equals(name)) {
+ Assert.assertTrue(checkImportedType(compilationUnit.getImportedTypes(), Arrays.asList(
+ LombokPlugin.EnumLombokAnnotations.DATA,
+ LombokPlugin.EnumLombokAnnotations.SUPER_BUILDER,
+ LombokPlugin.EnumLombokAnnotations.NO_ARGS_CONSTRUCTOR,
+ LombokPlugin.EnumLombokAnnotations.ALL_ARGS_CONSTRUCTOR,
+ LombokPlugin.EnumLombokAnnotations.EQUALS_AND_HASH_CODE_CALL_SUPER
+ ), true));
+
+ Assert.assertFalse(checkImportedType(compilationUnit.getImportedTypes(), Arrays.asList(
+ LombokPlugin.EnumLombokAnnotations.BUILDER
+ ), false));
+ }
+
+ // tb 没有继承
+ if ("Tb".equals(name)) {
+ Assert.assertTrue(checkImportedType(compilationUnit.getImportedTypes(), Arrays.asList(
+ LombokPlugin.EnumLombokAnnotations.DATA,
+ LombokPlugin.EnumLombokAnnotations.BUILDER,
+ LombokPlugin.EnumLombokAnnotations.NO_ARGS_CONSTRUCTOR,
+ LombokPlugin.EnumLombokAnnotations.ALL_ARGS_CONSTRUCTOR
+ ), true));
+
+ Assert.assertFalse(checkImportedType(compilationUnit.getImportedTypes(), Arrays.asList(
+ LombokPlugin.EnumLombokAnnotations.SUPER_BUILDER,
+ LombokPlugin.EnumLombokAnnotations.EQUALS_AND_HASH_CODE_CALL_SUPER
+ ), false));
+ }
+
+ if ("TbKeysKey".equals(name)) {
+ Assert.assertTrue(checkImportedType(compilationUnit.getImportedTypes(), Arrays.asList(
+ LombokPlugin.EnumLombokAnnotations.DATA,
+ LombokPlugin.EnumLombokAnnotations.SUPER_BUILDER,
+ LombokPlugin.EnumLombokAnnotations.NO_ARGS_CONSTRUCTOR,
+ LombokPlugin.EnumLombokAnnotations.ALL_ARGS_CONSTRUCTOR
+ ), true));
+
+ Assert.assertFalse(checkImportedType(compilationUnit.getImportedTypes(), Arrays.asList(
+ LombokPlugin.EnumLombokAnnotations.BUILDER,
+ LombokPlugin.EnumLombokAnnotations.EQUALS_AND_HASH_CODE_CALL_SUPER
+ ), false));
+ } else if ("TbKeys".equals(name)) {
+ Assert.assertTrue(checkImportedType(compilationUnit.getImportedTypes(), Arrays.asList(
+ LombokPlugin.EnumLombokAnnotations.DATA,
+ LombokPlugin.EnumLombokAnnotations.SUPER_BUILDER,
+ LombokPlugin.EnumLombokAnnotations.NO_ARGS_CONSTRUCTOR,
+ LombokPlugin.EnumLombokAnnotations.ALL_ARGS_CONSTRUCTOR,
+ LombokPlugin.EnumLombokAnnotations.EQUALS_AND_HASH_CODE_CALL_SUPER
+ ), true));
+
+ Assert.assertFalse(checkImportedType(compilationUnit.getImportedTypes(), Arrays.asList(
+ LombokPlugin.EnumLombokAnnotations.BUILDER
+ ), false));
+ }
}
}
+ /**
+ * 测试具体生成
+ */
@Test
- public void test() throws Exception {
- MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/LombokPlugin/mybatis-generator.xml");
+ public void testGenerateDefault() throws Exception {
+ MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/LombokPlugin/mybatis-generator-default.xml");
+ MyBatisGenerator myBatisGenerator = tool.generate();
+ for (GeneratedJavaFile file : myBatisGenerator.getGeneratedJavaFiles()) {
+ CompilationUnit compilationUnit = file.getCompilationUnit();
+ String name = compilationUnit.getType().getShortName();
+ if ("TbKeyBlobKey".equals(name)) {
+ Assert.assertTrue(checkImportedType(compilationUnit.getImportedTypes(), Arrays.asList(
+ LombokPlugin.EnumLombokAnnotations.DATA
+
+ ), true));
+
+ Assert.assertFalse(checkImportedType(compilationUnit.getImportedTypes(), Arrays.asList(
+ LombokPlugin.EnumLombokAnnotations.BUILDER,
+ LombokPlugin.EnumLombokAnnotations.EQUALS_AND_HASH_CODE_CALL_SUPER,
+ LombokPlugin.EnumLombokAnnotations.SUPER_BUILDER,
+ LombokPlugin.EnumLombokAnnotations.NO_ARGS_CONSTRUCTOR,
+ LombokPlugin.EnumLombokAnnotations.ALL_ARGS_CONSTRUCTOR
+ ), false));
+ } else if ("TbKeyBlobWithBLOBs".equals(name)) {
+ Assert.assertTrue(checkImportedType(compilationUnit.getImportedTypes(), Arrays.asList(
+ LombokPlugin.EnumLombokAnnotations.DATA,
+ LombokPlugin.EnumLombokAnnotations.EQUALS_AND_HASH_CODE_CALL_SUPER
+ ), true));
+
+ Assert.assertFalse(checkImportedType(compilationUnit.getImportedTypes(), Arrays.asList(
+ LombokPlugin.EnumLombokAnnotations.BUILDER,
+ LombokPlugin.EnumLombokAnnotations.SUPER_BUILDER,
+ LombokPlugin.EnumLombokAnnotations.NO_ARGS_CONSTRUCTOR,
+ LombokPlugin.EnumLombokAnnotations.ALL_ARGS_CONSTRUCTOR
+
+ ), false));
+ }
+
+ // tb 没有继承
+ if ("Tb".equals(name)) {
+ Assert.assertTrue(checkImportedType(compilationUnit.getImportedTypes(), Arrays.asList(
+ LombokPlugin.EnumLombokAnnotations.DATA
+ ), true));
+
+ Assert.assertFalse(checkImportedType(compilationUnit.getImportedTypes(), Arrays.asList(
+ LombokPlugin.EnumLombokAnnotations.SUPER_BUILDER,
+ LombokPlugin.EnumLombokAnnotations.EQUALS_AND_HASH_CODE_CALL_SUPER,
+ LombokPlugin.EnumLombokAnnotations.BUILDER,
+ LombokPlugin.EnumLombokAnnotations.NO_ARGS_CONSTRUCTOR,
+ LombokPlugin.EnumLombokAnnotations.ALL_ARGS_CONSTRUCTOR
+ ), false));
+ }
+ }
+ }
+
+ /**
+ * 测试 @Data 注解
+ * @throws Exception
+ */
+ @Test
+ public void testDataAnnotation() throws Exception {
+ MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/LombokPlugin/mybatis-generator-data.xml");
tool.generate(new AbstractShellCallback() {
@Override
- public void reloadProject(SqlSession sqlSession, ClassLoader loader, String packagz) throws Exception{
- System.out.println("xxx");
+ public void reloadProject(SqlSession sqlSession, ClassLoader loader, String packagz) throws Exception {
+
+ // get & set
+ ObjectUtil tbLombok = new ObjectUtil(loader, packagz + ".TbLombok");
+ tbLombok.invoke("setField1", "ts1");
+ Assert.assertEquals(tbLombok.invoke("getField1"), "ts1");
+ // get & set with parent
+ tbLombok.invoke("setKey1", "ts2");
+ Assert.assertEquals(tbLombok.invoke("getKey1"), "ts2");
+ // get & set with Boolean
+ tbLombok.invoke("setIsFind", true);
+ Assert.assertEquals(tbLombok.invoke("getIsFind"), true);
+
+ // equals & hash & toString
+ ObjectUtil tbLombok1 = new ObjectUtil(loader, packagz + ".TbLombok");
+ tbLombok1.invoke("setField1", "ts1");
+ ObjectUtil tbLombok2 = new ObjectUtil(loader, packagz + ".TbLombok");
+ tbLombok2.invoke("setField1", "ts1");
+ Assert.assertEquals(tbLombok1.invoke("equals", tbLombok2.getObject()), true);
+ Assert.assertEquals(tbLombok1.invoke("hashCode"), tbLombok2.invoke("hashCode"));
+ Assert.assertEquals(tbLombok1.invoke("toString"), "TbLombok(super=TbLombokKey(id=null, key1=null), field1=ts1, isFind=null)");
+
+ // equals & hash & toString with parent
+ tbLombok1.invoke("setKey1", "ts2");
+ tbLombok2.invoke("setKey1", "ts2");
+ Assert.assertEquals(tbLombok1.invoke("equals", tbLombok2.getObject()), true);
+ Assert.assertEquals(tbLombok1.invoke("hashCode"), tbLombok2.invoke("hashCode"));
+ Assert.assertEquals(tbLombok1.invoke("toString"), "TbLombok(super=TbLombokKey(id=null, key1=ts2), field1=ts1, isFind=null)");
+ // @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true)
+ tbLombok1.invoke("setId", 1L);
+ Assert.assertEquals(tbLombok1.invoke("equals", tbLombok2.getObject()), false);
+ Assert.assertNotEquals(tbLombok1.invoke("hashCode"), tbLombok2.invoke("hashCode"));
+ Assert.assertEquals(tbLombok1.invoke("toString"), "TbLombok(super=TbLombokKey(id=1, key1=ts2), field1=ts1, isFind=null)");
}
});
}
+
+ /**
+ * 测试 @Builder 注解
+ * @throws Exception
+ */
+ @Test
+ public void testBuilderAnnotation() throws Exception {
+ MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/LombokPlugin/mybatis-generator-builder.xml");
+ tool.generate(new AbstractShellCallback() {
+ @Override
+ public void reloadProject(SqlSession sqlSession, ClassLoader loader, String packagz) throws Exception {
+ // normal builder
+ ObjectUtil tbBuilder = new ObjectUtil(loader.loadClass(packagz + ".Tb").getMethod("builder").invoke(null));
+ tbBuilder = new ObjectUtil(tbBuilder.invoke("id", 1L));
+ tbBuilder.invoke("field1", "ts1");
+ ObjectUtil tb = new ObjectUtil(tbBuilder.invoke("build"));
+ Assert.assertEquals(tb.invoke("toString"), "Tb(id=1, field1=ts1, field2=null)");
+
+ // super builder
+ ObjectUtil tbLombokBuilder = new ObjectUtil(loader.loadClass(packagz + ".TbLombok").getMethod("builder").invoke(null));
+ tbLombokBuilder.invoke("field1", "ts1");
+ Assert.assertEquals(tbLombokBuilder.invoke("toString"), "TbLombok.TbLombokBuilder(super=TbLombokKey.TbLombokKeyBuilder(id=null, key1=null), field1=ts1, isFind=null)");
+ tbLombokBuilder.invoke("id", 100L);
+ Assert.assertEquals(tbLombokBuilder.invoke("toString"), "TbLombok.TbLombokBuilder(super=TbLombokKey.TbLombokKeyBuilder(id=100, key1=null), field1=ts1, isFind=null)");
+ }
+ });
+ }
+
+ /**
+ * 测试 @NoArgsConstructor @AllArgsConstructor 注解
+ * @throws Exception
+ */
+ @Test
+ public void testConstructorAnnotation() throws Exception {
+ MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/LombokPlugin/mybatis-generator-constructor.xml");
+ tool.generate(new AbstractShellCallback() {
+ @Override
+ public void reloadProject(SqlSession sqlSession, ClassLoader loader, String packagz) throws Exception {
+ Class clazz = loader.loadClass(packagz + ".TbLombok");
+ try {
+ // 无参
+ ObjectUtil tbLombok = new ObjectUtil(clazz.newInstance());
+ Assert.assertEquals(tbLombok.invoke("toString"), "TbLombok(super=TbLombokKey(id=null, key1=null), field1=null, isFind=null)");
+
+ // 有参
+ Constructor constructor = clazz.getConstructor(String.class, Boolean.class);
+
+ tbLombok = new ObjectUtil(constructor.newInstance("ts1", true));
+ Assert.assertEquals(tbLombok.invoke("toString"), "TbLombok(super=TbLombokKey(id=null, key1=null), field1=ts1, isFind=true)");
+
+ } catch (Exception e) {
+ Assert.assertTrue(false);
+ }
+ }
+ });
+ }
+
+ /**
+ * 验证引包
+ * @param importedTypes
+ * @param annotations
+ * @param all
+ * @return
+ */
+ private boolean checkImportedType(Set importedTypes, List annotations, boolean all) {
+ for (LombokPlugin.EnumLombokAnnotations annotation : annotations) {
+ boolean find = false;
+ for (FullyQualifiedJavaType javaType : importedTypes) {
+ if (javaType.getFullyQualifiedName().equals(annotation.getClazz())) {
+ if (all) {
+ find = true;
+ } else {
+ return true;
+ }
+ }
+ }
+ if (find == false) {
+ return false;
+ }
+ }
+
+ return true;
+ }
}
diff --git a/src/test/resources/scripts/LombokPlugin/init.sql b/src/test/resources/scripts/LombokPlugin/init.sql
index d44b036..d589dae 100644
--- a/src/test/resources/scripts/LombokPlugin/init.sql
+++ b/src/test/resources/scripts/LombokPlugin/init.sql
@@ -29,28 +29,6 @@ CREATE TABLE `tb` (
-- ----------------------------
-- Records of tb
-- ----------------------------
-INSERT INTO `tb` VALUES ('1', 'fd1', null);
-INSERT INTO `tb` VALUES ('2', null, '2');
-INSERT INTO `tb` VALUES ('3', 'fd3', '3');
-
--- ----------------------------
--- Table structure for tb_blobs
--- ----------------------------
-DROP TABLE IF EXISTS `tb_blobs`;
-CREATE TABLE `tb_blobs` (
- `id` bigint(20) NOT NULL COMMENT '注释1',
- `field1` varchar(255) DEFAULT NULL,
- `field2` longtext COMMENT '注释2',
- `field3` longtext,
- PRIMARY KEY (`id`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-
--- ----------------------------
--- Records of tb_blobs
--- ----------------------------
-INSERT INTO `tb_blobs` VALUES ('1', 'fd1', null, 'KK1');
-INSERT INTO `tb_blobs` VALUES ('2', null, '2', null);
-INSERT INTO `tb_blobs` VALUES ('3', 'fd3', '3', 'KK3');
-- ----------------------------
-- Table structure for tb_keys
@@ -67,21 +45,37 @@ CREATE TABLE `tb_keys` (
-- ----------------------------
-- Records of tb_keys
-- ----------------------------
-INSERT INTO `tb_keys` VALUES ('1', '2', 'fd1', null);
-INSERT INTO `tb_keys` VALUES ('2', '3', null, '2');
-INSERT INTO `tb_keys` VALUES ('3', '4', 'fd2', '3');
-- ----------------------------
--- Table structure for tb_single_blob
+-- Table structure for tb_key_blob
-- ----------------------------
-DROP TABLE IF EXISTS `tb_single_blob`;
-CREATE TABLE `tb_single_blob` (
+DROP TABLE IF EXISTS `tb_key_blob`;
+CREATE TABLE `tb_key_blob` (
`id` bigint(20) NOT NULL COMMENT '注释1',
+ `key1` varchar(20) NOT NULL,
`field1` longtext COMMENT '注释2',
- `field2` int(11) DEFAULT NULL,
- PRIMARY KEY (`id`)
+ `field2` longtext,
+ PRIMARY KEY (`id`,`key1`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- ----------------------------
--- Records of tb_single_blob
+-- Records of tb_key_blob
+-- ----------------------------
+
+-- ----------------------------
+-- Table structure for tb_lombok
+-- ----------------------------
+DROP TABLE IF EXISTS `tb_lombok`;
+CREATE TABLE `tb_lombok` (
+ `id` bigint(20) NOT NULL COMMENT '注释1',
+ `key1` varchar(20) NOT NULL,
+ `field1` varchar(10) COMMENT '注释2',
+ `is_find` tinyint(1),
+ `field3` longtext,
+ `field4` longtext,
+ PRIMARY KEY (`id`,`key1`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+-- ----------------------------
+-- Records of tb_lombok
-- ----------------------------
\ No newline at end of file
diff --git a/src/test/resources/scripts/LombokPlugin/mybatis-generator-builder.xml b/src/test/resources/scripts/LombokPlugin/mybatis-generator-builder.xml
new file mode 100644
index 0000000..f4c6be8
--- /dev/null
+++ b/src/test/resources/scripts/LombokPlugin/mybatis-generator-builder.xml
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/scripts/LombokPlugin/mybatis-generator-constructor.xml b/src/test/resources/scripts/LombokPlugin/mybatis-generator-constructor.xml
new file mode 100644
index 0000000..d8d7820
--- /dev/null
+++ b/src/test/resources/scripts/LombokPlugin/mybatis-generator-constructor.xml
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/scripts/LombokPlugin/mybatis-generator-data.xml b/src/test/resources/scripts/LombokPlugin/mybatis-generator-data.xml
new file mode 100644
index 0000000..cf58cf2
--- /dev/null
+++ b/src/test/resources/scripts/LombokPlugin/mybatis-generator-data.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/scripts/LombokPlugin/mybatis-generator-default.xml b/src/test/resources/scripts/LombokPlugin/mybatis-generator-default.xml
new file mode 100644
index 0000000..4c4b619
--- /dev/null
+++ b/src/test/resources/scripts/LombokPlugin/mybatis-generator-default.xml
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/scripts/LombokPlugin/mybatis-generator.xml b/src/test/resources/scripts/LombokPlugin/mybatis-generator.xml
index 32ed7ba..76b0fb3 100644
--- a/src/test/resources/scripts/LombokPlugin/mybatis-generator.xml
+++ b/src/test/resources/scripts/LombokPlugin/mybatis-generator.xml
@@ -46,7 +46,6 @@
-
-
+
\ No newline at end of file