diff --git a/mmegp-annotations/src/main/java/me/ningpp/mmegp/annotations/GeneratedColumn.java b/mmegp-annotations/src/main/java/me/ningpp/mmegp/annotations/Column.java similarity index 98% rename from mmegp-annotations/src/main/java/me/ningpp/mmegp/annotations/GeneratedColumn.java rename to mmegp-annotations/src/main/java/me/ningpp/mmegp/annotations/Column.java index abf33a1..dfd70e7 100644 --- a/mmegp-annotations/src/main/java/me/ningpp/mmegp/annotations/GeneratedColumn.java +++ b/mmegp-annotations/src/main/java/me/ningpp/mmegp/annotations/Column.java @@ -32,7 +32,7 @@ @Inherited @Target({ ElementType.FIELD }) @Retention(RetentionPolicy.RUNTIME) -public @interface GeneratedColumn { +public @interface Column { /** * column name diff --git a/mmegp-annotations/src/main/java/me/ningpp/mmegp/annotations/Generated.java b/mmegp-annotations/src/main/java/me/ningpp/mmegp/annotations/Table.java similarity index 97% rename from mmegp-annotations/src/main/java/me/ningpp/mmegp/annotations/Generated.java rename to mmegp-annotations/src/main/java/me/ningpp/mmegp/annotations/Table.java index 68ae33e..b75ddce 100644 --- a/mmegp-annotations/src/main/java/me/ningpp/mmegp/annotations/Generated.java +++ b/mmegp-annotations/src/main/java/me/ningpp/mmegp/annotations/Table.java @@ -26,7 +26,7 @@ @Inherited @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.TYPE }) -public @interface Generated { +public @interface Table { /** * table name diff --git a/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-annotatedmapper/src/main/java/me/ningpp/mmegp/demo/entity/SysRole.java b/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-annotatedmapper/src/main/java/me/ningpp/mmegp/demo/entity/SysRole.java index 81d14ca..db0d6ea 100644 --- a/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-annotatedmapper/src/main/java/me/ningpp/mmegp/demo/entity/SysRole.java +++ b/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-annotatedmapper/src/main/java/me/ningpp/mmegp/demo/entity/SysRole.java @@ -17,14 +17,14 @@ import org.apache.ibatis.type.JdbcType; -import me.ningpp.mmegp.annotations.Generated; -import me.ningpp.mmegp.annotations.GeneratedColumn; +import me.ningpp.mmegp.annotations.Table; +import me.ningpp.mmegp.annotations.Column; -@Generated(table = "sys_role") +@Table(table = "sys_role") public class SysRole { - @GeneratedColumn(name = "id", jdbcType = JdbcType.VARCHAR, id = true) + @Column(name = "id", jdbcType = JdbcType.VARCHAR, id = true) private String id; - @GeneratedColumn(name = "name", jdbcType = JdbcType.VARCHAR, id = false) + @Column(name = "name", jdbcType = JdbcType.VARCHAR, id = false) private String name; public String getId() { return id; diff --git a/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-dynamic-sql/src/main/java/me/ningpp/mmegp/demo/entity/SysAutoUser.java b/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-dynamic-sql/src/main/java/me/ningpp/mmegp/demo/entity/SysAutoUser.java index b44bc18..5eab4c9 100644 --- a/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-dynamic-sql/src/main/java/me/ningpp/mmegp/demo/entity/SysAutoUser.java +++ b/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-dynamic-sql/src/main/java/me/ningpp/mmegp/demo/entity/SysAutoUser.java @@ -1,19 +1,19 @@ package me.ningpp.mmegp.demo.entity; -import me.ningpp.mmegp.annotations.Generated; -import me.ningpp.mmegp.annotations.GeneratedColumn; +import me.ningpp.mmegp.annotations.Table; +import me.ningpp.mmegp.annotations.Column; import me.ningpp.mmegp.annotations.SoftDelete; -@Generated +@Table @SoftDelete(column = "deleted") public class SysAutoUser { - @GeneratedColumn(id = true, generatedValue = true) + @Column(id = true, generatedValue = true) private Integer id; - @GeneratedColumn + @Column private String firstName; - @GeneratedColumn + @Column private String lastName; - @GeneratedColumn + @Column private Byte deleted; public Integer getId() { diff --git a/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-dynamic-sql/src/main/java/me/ningpp/mmegp/demo/entity2/SysOrg.java b/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-dynamic-sql/src/main/java/me/ningpp/mmegp/demo/entity2/SysOrg.java index b513bc4..955293e 100644 --- a/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-dynamic-sql/src/main/java/me/ningpp/mmegp/demo/entity2/SysOrg.java +++ b/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-dynamic-sql/src/main/java/me/ningpp/mmegp/demo/entity2/SysOrg.java @@ -15,21 +15,21 @@ */ package me.ningpp.mmegp.demo.entity2; -import me.ningpp.mmegp.annotations.Generated; -import me.ningpp.mmegp.annotations.GeneratedColumn; +import me.ningpp.mmegp.annotations.Table; +import me.ningpp.mmegp.annotations.Column; import me.ningpp.mmegp.annotations.SoftDelete; import org.apache.ibatis.type.JdbcType; -@Generated(table = "sys_org") +@Table(table = "sys_org") @SoftDelete(column = "deleted") public class SysOrg { - @GeneratedColumn(name = "id", jdbcType = JdbcType.VARCHAR, id = true) + @Column(name = "id", jdbcType = JdbcType.VARCHAR, id = true) private String id; - @GeneratedColumn(name = "name", jdbcType = JdbcType.VARCHAR) + @Column(name = "name", jdbcType = JdbcType.VARCHAR) private String name; - @GeneratedColumn(name = "deleted", jdbcType = JdbcType.TINYINT) + @Column(name = "deleted", jdbcType = JdbcType.TINYINT) private Byte deleted; public SysOrg() { diff --git a/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-dynamic-sql/src/main/java/me/ningpp/mmegp/demo/entity2/SysOrg2.java b/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-dynamic-sql/src/main/java/me/ningpp/mmegp/demo/entity2/SysOrg2.java index 5197668..9067e51 100644 --- a/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-dynamic-sql/src/main/java/me/ningpp/mmegp/demo/entity2/SysOrg2.java +++ b/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-dynamic-sql/src/main/java/me/ningpp/mmegp/demo/entity2/SysOrg2.java @@ -15,24 +15,24 @@ */ package me.ningpp.mmegp.demo.entity2; -import me.ningpp.mmegp.annotations.Generated; -import me.ningpp.mmegp.annotations.GeneratedColumn; +import me.ningpp.mmegp.annotations.Table; +import me.ningpp.mmegp.annotations.Column; import me.ningpp.mmegp.annotations.SoftDelete; import me.ningpp.mmegp.enums.SoftDeleteStrategy; import org.apache.ibatis.type.JdbcType; import java.time.LocalDateTime; -@Generated(table = "sys_org2") +@Table(table = "sys_org2") @SoftDelete(column = "delete_time", strategy = SoftDeleteStrategy.DELETED_AT) public record SysOrg2( - @GeneratedColumn(name = "id", jdbcType = JdbcType.VARCHAR, id = true) + @Column(name = "id", jdbcType = JdbcType.VARCHAR, id = true) String id, - @GeneratedColumn(name = "name", jdbcType = JdbcType.VARCHAR) + @Column(name = "name", jdbcType = JdbcType.VARCHAR) String name, - @GeneratedColumn(name = "delete_time", jdbcType = JdbcType.TIMESTAMP) + @Column(name = "delete_time", jdbcType = JdbcType.TIMESTAMP) LocalDateTime deleteTime ) { } diff --git a/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-dynamic-sql/src/main/java/me/ningpp/mmegp/demo/entity2/SysUser.java b/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-dynamic-sql/src/main/java/me/ningpp/mmegp/demo/entity2/SysUser.java index 1c864c1..5ad4256 100644 --- a/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-dynamic-sql/src/main/java/me/ningpp/mmegp/demo/entity2/SysUser.java +++ b/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-dynamic-sql/src/main/java/me/ningpp/mmegp/demo/entity2/SysUser.java @@ -17,17 +17,17 @@ import org.apache.ibatis.type.JdbcType; -import me.ningpp.mmegp.annotations.Generated; -import me.ningpp.mmegp.annotations.GeneratedColumn; +import me.ningpp.mmegp.annotations.Table; +import me.ningpp.mmegp.annotations.Column; import org.apache.ibatis.type.StringTypeHandler; import static org.apache.ibatis.type.JdbcType.VARCHAR; -@Generated(table = "sys_user") +@Table(table = "sys_user") public class SysUser { - @GeneratedColumn(name = "id", jdbcType = VARCHAR, id = true, typeHandler = StringTypeHandler.class) + @Column(name = "id", jdbcType = VARCHAR, id = true, typeHandler = StringTypeHandler.class) private String id; - @GeneratedColumn(name = "name", jdbcType = JdbcType.VARCHAR) + @Column(name = "name", jdbcType = JdbcType.VARCHAR) private String name; public String getId() { return id; diff --git a/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-dynamic-sql/src/main/java/me/ningpp/mmegp/demo/entity3/SysCompany.java b/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-dynamic-sql/src/main/java/me/ningpp/mmegp/demo/entity3/SysCompany.java index 04e100d..db0813f 100644 --- a/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-dynamic-sql/src/main/java/me/ningpp/mmegp/demo/entity3/SysCompany.java +++ b/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-dynamic-sql/src/main/java/me/ningpp/mmegp/demo/entity3/SysCompany.java @@ -15,26 +15,26 @@ */ package me.ningpp.mmegp.demo.entity3; -import me.ningpp.mmegp.annotations.Generated; -import me.ningpp.mmegp.annotations.GeneratedColumn; +import me.ningpp.mmegp.annotations.Table; +import me.ningpp.mmegp.annotations.Column; import org.apache.ibatis.type.JdbcType; import java.time.LocalDate; import static org.apache.ibatis.type.JdbcType.VARCHAR; -@Generated(table = "sys_company") +@Table(table = "sys_company") public record SysCompany( - @GeneratedColumn(name = "id", jdbcType = VARCHAR, id = true) + @Column(name = "id", jdbcType = VARCHAR, id = true) String id, - @GeneratedColumn(name = "name", jdbcType = VARCHAR) + @Column(name = "name", jdbcType = VARCHAR) String name, - @GeneratedColumn(name = "start_date", jdbcType = JdbcType.DATE) + @Column(name = "start_date", jdbcType = JdbcType.DATE) LocalDate startDate, - @GeneratedColumn(name = "unified_code", jdbcType = VARCHAR) + @Column(name = "unified_code", jdbcType = VARCHAR) String unifiedCode ) { } diff --git a/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-mixedmapper/src/main/java/me/ningpp/mmegp/demo/entity/SysRoleMenu.java b/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-mixedmapper/src/main/java/me/ningpp/mmegp/demo/entity/SysRoleMenu.java index e3f3848..150484f 100644 --- a/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-mixedmapper/src/main/java/me/ningpp/mmegp/demo/entity/SysRoleMenu.java +++ b/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-mixedmapper/src/main/java/me/ningpp/mmegp/demo/entity/SysRoleMenu.java @@ -17,16 +17,16 @@ import org.apache.ibatis.type.JdbcType; -import me.ningpp.mmegp.annotations.Generated; -import me.ningpp.mmegp.annotations.GeneratedColumn; +import me.ningpp.mmegp.annotations.Table; +import me.ningpp.mmegp.annotations.Column; -@Generated(table = "sys_role_menu") +@Table(table = "sys_role_menu") public class SysRoleMenu { - @GeneratedColumn(name = "id", jdbcType = JdbcType.BIGINT, id = true, generatedValue = true) + @Column(name = "id", jdbcType = JdbcType.BIGINT, id = true, generatedValue = true) private Long id; - @GeneratedColumn(name = "role_id", jdbcType = JdbcType.VARCHAR, id = false) + @Column(name = "role_id", jdbcType = JdbcType.VARCHAR, id = false) private String roleId; - @GeneratedColumn(name = "menu_id", jdbcType = JdbcType.VARCHAR) + @Column(name = "menu_id", jdbcType = JdbcType.VARCHAR) private String menuId; public Long getId() { return id; diff --git a/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-mixedmapper/src/main/java2/me/ningpp/mmegp/demo/model/SysUserRole.java b/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-mixedmapper/src/main/java2/me/ningpp/mmegp/demo/model/SysUserRole.java index 626fcd1..de0c68b 100644 --- a/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-mixedmapper/src/main/java2/me/ningpp/mmegp/demo/model/SysUserRole.java +++ b/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-mixedmapper/src/main/java2/me/ningpp/mmegp/demo/model/SysUserRole.java @@ -17,16 +17,16 @@ import org.apache.ibatis.type.JdbcType; -import me.ningpp.mmegp.annotations.Generated; -import me.ningpp.mmegp.annotations.GeneratedColumn; +import me.ningpp.mmegp.annotations.Table; +import me.ningpp.mmegp.annotations.Column; -@Generated(table = "sys_user_role") +@Table(table = "sys_user_role") public class SysUserRole { - @GeneratedColumn(name = "id", jdbcType = JdbcType.BIGINT, id = true, generatedValue = true) + @Column(name = "id", jdbcType = JdbcType.BIGINT, id = true, generatedValue = true) private Long id; - @GeneratedColumn(name = "user_id", jdbcType = JdbcType.VARCHAR) + @Column(name = "user_id", jdbcType = JdbcType.VARCHAR) private String userId; - @GeneratedColumn(name = "role_id", jdbcType = JdbcType.VARCHAR, id = false) + @Column(name = "role_id", jdbcType = JdbcType.VARCHAR, id = false) private String roleId; public Long getId() { return id; diff --git a/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-xmlmapper/src/main/java/me/ningpp/mmegp/demo/entity/SysMenu.java b/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-xmlmapper/src/main/java/me/ningpp/mmegp/demo/entity/SysMenu.java index 7c420fc..5b0bf45 100644 --- a/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-xmlmapper/src/main/java/me/ningpp/mmegp/demo/entity/SysMenu.java +++ b/mmegp-maven-plugin-demo/mmegp-maven-plugin-demo-xmlmapper/src/main/java/me/ningpp/mmegp/demo/entity/SysMenu.java @@ -15,8 +15,8 @@ */ package me.ningpp.mmegp.demo.entity; -import me.ningpp.mmegp.annotations.Generated; -import me.ningpp.mmegp.annotations.GeneratedColumn; +import me.ningpp.mmegp.annotations.Table; +import me.ningpp.mmegp.annotations.Column; import me.ningpp.mmegp.mybatis.type.list.ListCommaIntegerTypeHandler; import me.ningpp.mmegp.mybatis.type.list.ListCommaLongTypeHandler; import me.ningpp.mmegp.mybatis.type.list.ListCommaStringTypeHandler; @@ -37,83 +37,83 @@ import java.util.Set; import java.util.UUID; -@Generated(table = "sys_menu") +@Table(table = "sys_menu") public class SysMenu { - @GeneratedColumn(name = "id", jdbcType = JdbcType.VARCHAR, id = true) + @Column(name = "id", jdbcType = JdbcType.VARCHAR, id = true) private String id; - @GeneratedColumn(name = "name", jdbcType = JdbcType.VARCHAR) + @Column(name = "name", jdbcType = JdbcType.VARCHAR) private String name; - @GeneratedColumn(name = "parent_id", jdbcType = JdbcType.VARCHAR) + @Column(name = "parent_id", jdbcType = JdbcType.VARCHAR) private String parentId; - @GeneratedColumn(name = "integer_list", jdbcType = JdbcType.VARCHAR, + @Column(name = "integer_list", jdbcType = JdbcType.VARCHAR, typeHandler = ListCommaIntegerTypeHandler.class ) private List integerList; - @GeneratedColumn(name = "long_list", jdbcType = JdbcType.VARCHAR, + @Column(name = "long_list", jdbcType = JdbcType.VARCHAR, typeHandler = ListCommaLongTypeHandler.class ) private List longList; - @GeneratedColumn(name = "string_list", jdbcType = JdbcType.VARCHAR, + @Column(name = "string_list", jdbcType = JdbcType.VARCHAR, typeHandler = ListCommaStringTypeHandler.class ) private List stringList; - @GeneratedColumn(name = "integer_set", jdbcType = JdbcType.VARCHAR, + @Column(name = "integer_set", jdbcType = JdbcType.VARCHAR, typeHandler = SetCommaIntegerTypeHandler.class ) private Set integerSet; - @GeneratedColumn(name = "long_set", jdbcType = JdbcType.VARCHAR, + @Column(name = "long_set", jdbcType = JdbcType.VARCHAR, typeHandler = SetCommaLongTypeHandler.class ) private Set longSet; - @GeneratedColumn(name = "string_set", jdbcType = JdbcType.VARCHAR, + @Column(name = "string_set", jdbcType = JdbcType.VARCHAR, typeHandler = SetCommaStringTypeHandler.class ) private Set stringSet; - @GeneratedColumn( + @Column( name = "integer_linkedhashset", jdbcType = JdbcType.VARCHAR, typeHandler = LinkedHashSetCommaIntegerTypeHandler.class ) private LinkedHashSet integerLinkedhashset; - @GeneratedColumn( + @Column( name = "long_linkedhashset", jdbcType = JdbcType.VARCHAR, typeHandler = LinkedHashSetCommaLongTypeHandler.class ) private HashSet longLinkedhashset; - @GeneratedColumn( + @Column( name = "string_linkedhashset", jdbcType = JdbcType.VARCHAR, typeHandler = LinkedHashSetCommaStringTypeHandler.class ) private Set stringLinkedhashset; - @GeneratedColumn(name = "bytes1", jdbcType = JdbcType.BINARY) + @Column(name = "bytes1", jdbcType = JdbcType.BINARY) private byte[] bytes1; - @GeneratedColumn(name = "bytes2", jdbcType = JdbcType.BINARY) + @Column(name = "bytes2", jdbcType = JdbcType.BINARY) private Byte[] bytes2; - @GeneratedColumn( + @Column( name = "uuid", jdbcType = JdbcType.BINARY, typeHandler = UUIDTypeHandler.class ) private UUID uuid; - @GeneratedColumn( + @Column( name = "with_dash_uuid", jdbcType = JdbcType.VARCHAR, typeHandler = UUIDStringTypeHandler.class ) private UUID withDashUUID; - @GeneratedColumn( + @Column( name = "no_dash_uuid", jdbcType = JdbcType.VARCHAR, typeHandler = UUIDNoDashStringTypeHandler.class ) diff --git a/mmegp-mbg-ext/src/main/java/me/ningpp/mmegp/DefaultIntrospectedTableBuilder.java b/mmegp-mbg-ext/src/main/java/me/ningpp/mmegp/DefaultIntrospectedTableBuilder.java index 373febf..5ddf872 100644 --- a/mmegp-mbg-ext/src/main/java/me/ningpp/mmegp/DefaultIntrospectedTableBuilder.java +++ b/mmegp-mbg-ext/src/main/java/me/ningpp/mmegp/DefaultIntrospectedTableBuilder.java @@ -32,8 +32,8 @@ import com.github.javaparser.ast.nodeTypes.NodeWithSimpleName; import com.github.javaparser.ast.nodeTypes.NodeWithType; import com.github.javaparser.ast.type.Type; -import me.ningpp.mmegp.annotations.Generated; -import me.ningpp.mmegp.annotations.GeneratedColumn; +import me.ningpp.mmegp.annotations.Table; +import me.ningpp.mmegp.annotations.Column; import me.ningpp.mmegp.enums.AggregateFunction; import me.ningpp.mmegp.enums.ModelType; import org.apache.commons.lang3.StringUtils; @@ -82,7 +82,7 @@ protected GeneratedTableInfo buildGeneratedTable(Context context, if (modelDeclaration == null || modelDeclaration.getFullyQualifiedName().isEmpty()) { return null; } - var annotationMembers = getNormalAnnotationMembers(modelDeclaration, Generated.class); + var annotationMembers = getNormalAnnotationMembers(modelDeclaration, Table.class); String tableName = parseTableName(annotationMembers, modelDeclaration.getNameAsString(), context); List countGroupByColumns = parseArrayString(annotationMembers, COUNT_GROUP_BY_COLUMNS_NAME); @@ -267,7 +267,7 @@ protected Pair b NodeWithAnnotations annotationNode, NodeWithType typeNode, NodeWithSimpleName nameNode) { - Optional annoOptional = annotationNode.getAnnotationByClass(GeneratedColumn.class); + Optional annoOptional = annotationNode.getAnnotationByClass(Column.class); if (annoOptional.isEmpty()) { return null; } diff --git a/mmegp-mbg-ext/src/main/java/me/ningpp/mmegp/plugins/AddMmegpAnnotationPlugin.java b/mmegp-mbg-ext/src/main/java/me/ningpp/mmegp/plugins/AddMmegpAnnotationPlugin.java index 6edddcb..ff56082 100644 --- a/mmegp-mbg-ext/src/main/java/me/ningpp/mmegp/plugins/AddMmegpAnnotationPlugin.java +++ b/mmegp-mbg-ext/src/main/java/me/ningpp/mmegp/plugins/AddMmegpAnnotationPlugin.java @@ -62,7 +62,7 @@ public boolean validate(List warnings) { @Override public boolean modelBaseRecordClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) { - topLevelClass.addImportedType("me.ningpp.mmegp.annotations.Generated"); + topLevelClass.addImportedType("me.ningpp.mmegp.annotations.Table"); List infos = new ArrayList<>(); infos.add(String.format(Locale.ROOT, "table = \"%s\"", @@ -80,10 +80,10 @@ public boolean modelBaseRecordClassGenerated(TopLevelClass topLevelClass, } topLevelClass.addAnnotation(String.format(Locale.ROOT, - "@Generated(%s)", + "@Table(%s)", String.join(DELIMITER, infos))); - topLevelClass.addImportedType("me.ningpp.mmegp.annotations.GeneratedColumn"); + topLevelClass.addImportedType("me.ningpp.mmegp.annotations.Column"); topLevelClass.addImportedType("org.apache.ibatis.type.JdbcType"); return true; @@ -143,7 +143,7 @@ public boolean modelFieldGenerated(Field field, TopLevelClass topLevelClass, } field.addAnnotation(String.format(Locale.ROOT, - "@GeneratedColumn(name = \"%s\", jdbcType = JdbcType.%s%s)", + "@Column(name = \"%s\", jdbcType = JdbcType.%s%s)", introspectedColumn.getActualColumnName(), introspectedColumn.getJdbcTypeName(), otherInfos.isEmpty() diff --git a/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/JavaParserUtilTest.java b/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/JavaParserUtilTest.java index 8909991..645b9bd 100644 --- a/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/JavaParserUtilTest.java +++ b/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/JavaParserUtilTest.java @@ -38,11 +38,11 @@ void getMatchedTypeTest() { "import me.ningpp.mmegp.mybatis.type.set.LinkedHashSetCommaStringTypeHandler;" + "import java.util.Set;\n" + "\n" + - "@Generated(table = \"sys_menu\")\n" + + "@Table(table = \"sys_menu\")\n" + "public class SysMenu {\n" + - " @GeneratedColumn(name = \"string_linkedhashset\", jdbcType = JdbcType.VARCHAR, typeHandler = LinkedHashSetCommaStringTypeHandler.class)\n" + + " @Column(name = \"string_linkedhashset\", jdbcType = JdbcType.VARCHAR, typeHandler = LinkedHashSetCommaStringTypeHandler.class)\n" + " private Set stringLinkedhashset;\n" + - " @GeneratedColumn(name = \"string_linkedhashset2\", jdbcType = JdbcType.VARCHAR, typeHandler = LinkedHashSetCommaStringTypeHandler.class)\n" + + " @Column(name = \"string_linkedhashset2\", jdbcType = JdbcType.VARCHAR, typeHandler = LinkedHashSetCommaStringTypeHandler.class)\n" + " private java.util.HashSet stringLinkedhashset2;\n" + "}"; diff --git a/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/MmeCompileUtilTest.java b/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/MmeCompileUtilTest.java index 1533417..f0ffcae 100644 --- a/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/MmeCompileUtilTest.java +++ b/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/MmeCompileUtilTest.java @@ -37,27 +37,27 @@ public class MmeCompileUtilTest { private static final String JAVA_SOURCE_FILE_CONTENT = " package me.ningpp.mmegp.entity;\r\n" + "\r\n" - + " import me.ningpp.mmegp.annotations.Generated;\r\n" - + " import me.ningpp.mmegp.annotations.GeneratedColumn;\r\n" + + " import me.ningpp.mmegp.annotations.Table;\r\n" + + " import me.ningpp.mmegp.annotations.Column;\r\n" + " import me.ningpp.mmegp.enums.AggregateFunction;\r\n" + " import org.apache.ibatis.type.JdbcType;\r\n" + "\r\n" - + " @Generated(table = \"test_entity\"%s)\r\n" + + " @Table(table = \"test_entity\"%s)\r\n" + " public class TestEntity {\r\n" - + " @GeneratedColumn(name = \"ID\", jdbcType = JdbcType.VARCHAR, id = true, blob = false, generatedValue = false, aggregates = {})\r\n" + + " @Column(name = \"ID\", jdbcType = JdbcType.VARCHAR, id = true, blob = false, generatedValue = false, aggregates = {})\r\n" + " private String id;\r\n" - + " @GeneratedColumn(name = \"DIC_ID\", jdbcType = JdbcType.VARCHAR, aggregates = AggregateFunction.MIN)\r\n" + + " @Column(name = \"DIC_ID\", jdbcType = JdbcType.VARCHAR, aggregates = AggregateFunction.MIN)\r\n" + " private Integer dicId;\r\n" - + " @GeneratedColumn(name = \"OF_YEAR\", jdbcType = JdbcType.INTEGER, aggregates = { AggregateFunction.MIN, AggregateFunction.MAX} )\r\n" + + " @Column(name = \"OF_YEAR\", jdbcType = JdbcType.INTEGER, aggregates = { AggregateFunction.MIN, AggregateFunction.MAX} )\r\n" + " private Integer ofYear;\r\n" + "\r\n" - + " @GeneratedColumn(name = \"IMAGE_DATA\", jdbcType = JdbcType.LONGVARBINARY, id = false, blob = true, generatedValue = false)\r\n" + + " @Column(name = \"IMAGE_DATA\", jdbcType = JdbcType.LONGVARBINARY, id = false, blob = true, generatedValue = false)\r\n" + " private byte[] imageData;\r\n" + "\r\n" - + " @GeneratedColumn(name = \"IMAGE_DATA2\", jdbcType = JdbcType.LONGVARBINARY, id = false, blob = true, generatedValue = false)\r\n" + + " @Column(name = \"IMAGE_DATA2\", jdbcType = JdbcType.LONGVARBINARY, id = false, blob = true, generatedValue = false)\r\n" + " private Byte[] imageData;\r\n" + "\r\n" - + " @GeneratedColumn(name = \"serial_number\", jdbcType = JdbcType.INTEGER, id = true, generatedValue = %s)\r\n" + + " @Column(name = \"serial_number\", jdbcType = JdbcType.INTEGER, id = true, generatedValue = %s)\r\n" + " private Integer serialNumber;\r\n" + "\r\n" + " public Integer getSerialNumber() {\r\n" @@ -113,16 +113,16 @@ public class MmeCompileUtilTest { @Test void parseRecordTest() throws InterruptedException { - String code = "import me.ningpp.mmegp.annotations.Generated;\n" + - "import me.ningpp.mmegp.annotations.GeneratedColumn;\n" + + String code = "import me.ningpp.mmegp.annotations.Table;\n" + + "import me.ningpp.mmegp.annotations.Column;\n" + "import org.apache.ibatis.type.JdbcType;\n" + "import org.apache.ibatis.type.StringTypeHandler;\n" + "import static org.apache.ibatis.type.JdbcType.VARCHAR;\n" + - "@Generated(table = \"sys_person\")\n" + + "@Table(table = \"sys_person\")\n" + "public record SysPerson(\n" + - " @GeneratedColumn(name = \"id\", jdbcType = VARCHAR, id = true, typeHandler = StringTypeHandler.class)\n" + + " @Column(name = \"id\", jdbcType = VARCHAR, id = true, typeHandler = StringTypeHandler.class)\n" + " String id,\n" + - " @GeneratedColumn(name = \"name\", jdbcType = JdbcType.VARCHAR, typeHandler = org.apache.ibatis.type.StringTypeHandler.class)\n" + + " @Column(name = \"name\", jdbcType = JdbcType.VARCHAR, typeHandler = org.apache.ibatis.type.StringTypeHandler.class)\n" + " String name\n" + ") {\n" + "}"; diff --git a/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/entity/BigEntity.java b/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/entity/BigEntity.java index 78c0daf..2462d94 100644 --- a/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/entity/BigEntity.java +++ b/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/entity/BigEntity.java @@ -15,8 +15,8 @@ */ package me.ningpp.mmegp.entity; -import me.ningpp.mmegp.annotations.Generated; -import me.ningpp.mmegp.annotations.GeneratedColumn; +import me.ningpp.mmegp.annotations.Table; +import me.ningpp.mmegp.annotations.Column; import me.ningpp.mmegp.mybatis.type.uuid.UUIDStringTypeHandler; import org.apache.ibatis.type.JdbcType; @@ -33,69 +33,69 @@ import static org.apache.ibatis.type.JdbcType.VARCHAR; -@Generated +@Table public class BigEntity { - @GeneratedColumn(id = true) + @Column(id = true) private String id; - @GeneratedColumn(name = "f_boolean") + @Column(name = "f_boolean") private boolean fboolean; - @GeneratedColumn(name = "f_byte") + @Column(name = "f_byte") private byte fbyte; - @GeneratedColumn(name = "f_bytes", jdbcType = JdbcType.BINARY) + @Column(name = "f_bytes", jdbcType = JdbcType.BINARY) private byte[] fbytes; - @GeneratedColumn(name = "field_bytes", jdbcType = JdbcType.BLOB, blob = true) + @Column(name = "field_bytes", jdbcType = JdbcType.BLOB, blob = true) private Byte[] fieldBytes; - @GeneratedColumn(name = "f_char") + @Column(name = "f_char") private char fchar; - @GeneratedColumn(name = "f_character") + @Column(name = "f_character") private Character fcharacter; - @GeneratedColumn(name = "f_short") + @Column(name = "f_short") private short fshort; - @GeneratedColumn + @Column private Short fieldShort; - @GeneratedColumn(name = "f_int") + @Column(name = "f_int") private int fint; - @GeneratedColumn + @Column private Integer fieldInteger; - @GeneratedColumn(name = "f_int2", jdbcType = JdbcType.TINYINT) + @Column(name = "f_int2", jdbcType = JdbcType.TINYINT) private int fint2; - @GeneratedColumn(name = "field_integer2", jdbcType = JdbcType.TINYINT) + @Column(name = "field_integer2", jdbcType = JdbcType.TINYINT) private Integer fieldInteger2; - @GeneratedColumn(name = "f_long") + @Column(name = "f_long") private long flong; - @GeneratedColumn + @Column private Long fieldLong; - @GeneratedColumn(name = "f_float") + @Column(name = "f_float") private float ffloat; - @GeneratedColumn + @Column private Float fieldFloat; - @GeneratedColumn(name = "f_double") + @Column(name = "f_double") private double fdouble; - @GeneratedColumn + @Column private Double fieldDouble; - @GeneratedColumn(name = "f_bigint") + @Column(name = "f_bigint") private BigInteger fbigint; - @GeneratedColumn(name = "f_bigdecimal") + @Column(name = "f_bigdecimal") private BigDecimal fbigdecimal; - @GeneratedColumn(name = "f_date") + @Column(name = "f_date") private Date fdate; - @GeneratedColumn(name = "f_sqldate") + @Column(name = "f_sqldate") private java.sql.Date fsqldate; - @GeneratedColumn(name = "f_timestamp") + @Column(name = "f_timestamp") private Timestamp ftimestamp; - @GeneratedColumn(name = "f_year") + @Column(name = "f_year") private Year fyear; - @GeneratedColumn(name = "f_yearmonth", jdbcType = VARCHAR) + @Column(name = "f_yearmonth", jdbcType = VARCHAR) private YearMonth fyearmonth; - @GeneratedColumn(name = "f_localdate") + @Column(name = "f_localdate") private LocalDate flocaldate; - @GeneratedColumn(name = "f_localtime") + @Column(name = "f_localtime") private LocalTime flocaltime; - @GeneratedColumn(name = "f_localdatetime") + @Column(name = "f_localdatetime") private LocalDateTime flocaldatetime; - @GeneratedColumn(name = "f_uuid", jdbcType = VARCHAR, typeHandler = UUIDStringTypeHandler.class) + @Column(name = "f_uuid", jdbcType = VARCHAR, typeHandler = UUIDStringTypeHandler.class) private UUID fuuid; - @GeneratedColumn(name = "f_content", jdbcType = JdbcType.VARCHAR, blob = true) + @Column(name = "f_content", jdbcType = JdbcType.VARCHAR, blob = true) private String fcontent; public String getId() { diff --git a/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/entity/BigRecordEntity.java b/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/entity/BigRecordEntity.java index 217e4e9..d07feed 100644 --- a/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/entity/BigRecordEntity.java +++ b/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/entity/BigRecordEntity.java @@ -15,18 +15,18 @@ */ package me.ningpp.mmegp.entity; -import me.ningpp.mmegp.annotations.Generated; -import me.ningpp.mmegp.annotations.GeneratedColumn; +import me.ningpp.mmegp.annotations.Table; +import me.ningpp.mmegp.annotations.Column; import org.apache.ibatis.type.JdbcType; import static org.apache.ibatis.type.JdbcType.VARCHAR; -@Generated +@Table public record BigRecordEntity( - @GeneratedColumn(name = "id", jdbcType = VARCHAR, id = true) + @Column(name = "id", jdbcType = VARCHAR, id = true) String id, - @GeneratedColumn(name = "name", jdbcType = JdbcType.VARCHAR) + @Column(name = "name", jdbcType = JdbcType.VARCHAR) String name ) { } diff --git a/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity.java b/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity.java index ace6bd5..9c1adb9 100644 --- a/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity.java +++ b/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity.java @@ -15,19 +15,19 @@ */ package me.ningpp.mmegp.softdelete; -import me.ningpp.mmegp.annotations.Generated; -import me.ningpp.mmegp.annotations.GeneratedColumn; +import me.ningpp.mmegp.annotations.Table; +import me.ningpp.mmegp.annotations.Column; import me.ningpp.mmegp.annotations.SoftDelete; import org.apache.ibatis.type.JdbcType; -@Generated(table = "SoftDeleteEntity") +@Table(table = "SoftDeleteEntity") @SoftDelete(column = "deleted") public record SoftDeleteEntity( - @GeneratedColumn(name = "id", jdbcType = JdbcType.VARCHAR, id = true) + @Column(name = "id", jdbcType = JdbcType.VARCHAR, id = true) String id, - @GeneratedColumn(name = "name", jdbcType = JdbcType.VARCHAR) + @Column(name = "name", jdbcType = JdbcType.VARCHAR) String name, - @GeneratedColumn(name = "deleted", jdbcType = JdbcType.TINYINT) + @Column(name = "deleted", jdbcType = JdbcType.TINYINT) Byte deleted ) { } diff --git a/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity2.java b/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity2.java index f0345a7..c4b89f0 100644 --- a/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity2.java +++ b/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity2.java @@ -15,19 +15,19 @@ */ package me.ningpp.mmegp.softdelete; -import me.ningpp.mmegp.annotations.Generated; -import me.ningpp.mmegp.annotations.GeneratedColumn; +import me.ningpp.mmegp.annotations.Table; +import me.ningpp.mmegp.annotations.Column; import me.ningpp.mmegp.annotations.SoftDelete; import org.apache.ibatis.type.JdbcType; -@Generated(table = "SoftDeleteEntity2") +@Table(table = "SoftDeleteEntity2") @SoftDelete(column = "not_deleted", notDeletedValue = "1", deletedValue = "0") public record SoftDeleteEntity2( - @GeneratedColumn(name = "id", jdbcType = JdbcType.VARCHAR, id = true) + @Column(name = "id", jdbcType = JdbcType.VARCHAR, id = true) String id, - @GeneratedColumn(name = "name", jdbcType = JdbcType.VARCHAR) + @Column(name = "name", jdbcType = JdbcType.VARCHAR) String name, - @GeneratedColumn(name = "not_deleted", jdbcType = JdbcType.TINYINT) + @Column(name = "not_deleted", jdbcType = JdbcType.TINYINT) Integer notDeleted ) { } diff --git a/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity3.java b/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity3.java index 5a164a9..76c8cae 100644 --- a/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity3.java +++ b/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity3.java @@ -15,19 +15,19 @@ */ package me.ningpp.mmegp.softdelete; -import me.ningpp.mmegp.annotations.Generated; -import me.ningpp.mmegp.annotations.GeneratedColumn; +import me.ningpp.mmegp.annotations.Table; +import me.ningpp.mmegp.annotations.Column; import me.ningpp.mmegp.annotations.SoftDelete; import org.apache.ibatis.type.JdbcType; -@Generated(table = "SoftDeleteEntity3") +@Table(table = "SoftDeleteEntity3") @SoftDelete(column = "deleted") public record SoftDeleteEntity3( - @GeneratedColumn(name = "id", jdbcType = JdbcType.VARCHAR, id = true) + @Column(name = "id", jdbcType = JdbcType.VARCHAR, id = true) String id, - @GeneratedColumn(name = "name", jdbcType = JdbcType.VARCHAR) + @Column(name = "name", jdbcType = JdbcType.VARCHAR) String name, - @GeneratedColumn(name = "deleted", jdbcType = JdbcType.BOOLEAN) + @Column(name = "deleted", jdbcType = JdbcType.BOOLEAN) Boolean deleted ) { } diff --git a/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity4.java b/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity4.java index c62f595..29ed677 100644 --- a/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity4.java +++ b/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity4.java @@ -15,22 +15,22 @@ */ package me.ningpp.mmegp.softdelete; -import me.ningpp.mmegp.annotations.Generated; -import me.ningpp.mmegp.annotations.GeneratedColumn; +import me.ningpp.mmegp.annotations.Table; +import me.ningpp.mmegp.annotations.Column; import me.ningpp.mmegp.annotations.SoftDelete; import me.ningpp.mmegp.enums.SoftDeleteStrategy; import org.apache.ibatis.type.JdbcType; import java.time.LocalDateTime; -@Generated(table = "SoftDeleteEntity4") +@Table(table = "SoftDeleteEntity4") @SoftDelete(column = "delete_time", strategy = SoftDeleteStrategy.DELETED_AT) public record SoftDeleteEntity4( - @GeneratedColumn(name = "id", jdbcType = JdbcType.VARCHAR, id = true) + @Column(name = "id", jdbcType = JdbcType.VARCHAR, id = true) String id, - @GeneratedColumn(name = "name", jdbcType = JdbcType.VARCHAR) + @Column(name = "name", jdbcType = JdbcType.VARCHAR) String name, - @GeneratedColumn(name = "delete_time", jdbcType = JdbcType.TIMESTAMP) + @Column(name = "delete_time", jdbcType = JdbcType.TIMESTAMP) LocalDateTime deleteTime ) { } diff --git a/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity5.java b/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity5.java index 3d2c927..183628c 100644 --- a/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity5.java +++ b/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity5.java @@ -15,22 +15,22 @@ */ package me.ningpp.mmegp.softdelete; -import me.ningpp.mmegp.annotations.Generated; -import me.ningpp.mmegp.annotations.GeneratedColumn; +import me.ningpp.mmegp.annotations.Table; +import me.ningpp.mmegp.annotations.Column; import me.ningpp.mmegp.annotations.SoftDelete; import me.ningpp.mmegp.enums.SoftDeleteStrategy; import org.apache.ibatis.type.JdbcType; import java.util.Date; -@Generated(table = "SoftDeleteEntity5") +@Table(table = "SoftDeleteEntity5") @SoftDelete(column = "delete_time", strategy = SoftDeleteStrategy.DELETED_AT) public record SoftDeleteEntity5( - @GeneratedColumn(name = "id", jdbcType = JdbcType.VARCHAR, id = true) + @Column(name = "id", jdbcType = JdbcType.VARCHAR, id = true) String id, - @GeneratedColumn(name = "name", jdbcType = JdbcType.VARCHAR) + @Column(name = "name", jdbcType = JdbcType.VARCHAR) String name, - @GeneratedColumn(name = "delete_time", jdbcType = JdbcType.TIMESTAMP) + @Column(name = "delete_time", jdbcType = JdbcType.TIMESTAMP) Date deleteTime ) { } diff --git a/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity6.java b/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity6.java index 45273eb..b1b6053 100644 --- a/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity6.java +++ b/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity6.java @@ -15,19 +15,19 @@ */ package me.ningpp.mmegp.softdelete; -import me.ningpp.mmegp.annotations.Generated; -import me.ningpp.mmegp.annotations.GeneratedColumn; +import me.ningpp.mmegp.annotations.Table; +import me.ningpp.mmegp.annotations.Column; import me.ningpp.mmegp.annotations.SoftDelete; import org.apache.ibatis.type.JdbcType; -@Generated(table = "SoftDeleteEntity6") +@Table(table = "SoftDeleteEntity6") @SoftDelete(column = "deleted") public record SoftDeleteEntity6( - @GeneratedColumn(name = "id", jdbcType = JdbcType.VARCHAR, id = true) + @Column(name = "id", jdbcType = JdbcType.VARCHAR, id = true) String id, - @GeneratedColumn(name = "name", jdbcType = JdbcType.VARCHAR) + @Column(name = "name", jdbcType = JdbcType.VARCHAR) String name, - @GeneratedColumn(name = "deleted", jdbcType = JdbcType.VARCHAR) + @Column(name = "deleted", jdbcType = JdbcType.VARCHAR) String deleted ) { } diff --git a/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity7.java b/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity7.java index 334c942..6eafe75 100644 --- a/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity7.java +++ b/mmegp-mbg-ext/src/test/java/me/ningpp/mmegp/softdelete/SoftDeleteEntity7.java @@ -15,19 +15,19 @@ */ package me.ningpp.mmegp.softdelete; -import me.ningpp.mmegp.annotations.Generated; -import me.ningpp.mmegp.annotations.GeneratedColumn; +import me.ningpp.mmegp.annotations.Table; +import me.ningpp.mmegp.annotations.Column; import me.ningpp.mmegp.annotations.SoftDelete; import org.apache.ibatis.type.JdbcType; -@Generated(table = "SoftDeleteEntity7") +@Table(table = "SoftDeleteEntity7") @SoftDelete(column = "deleted") public class SoftDeleteEntity7 { - @GeneratedColumn(name = "id", jdbcType = JdbcType.VARCHAR, id = true) + @Column(name = "id", jdbcType = JdbcType.VARCHAR, id = true) private String id; - @GeneratedColumn(name = "name", jdbcType = JdbcType.VARCHAR) + @Column(name = "name", jdbcType = JdbcType.VARCHAR) private String name; - @GeneratedColumn(name = "deleted", jdbcType = JdbcType.TINYINT) + @Column(name = "deleted", jdbcType = JdbcType.TINYINT) private Byte deleted; public String getId() {