From 4242ed9cb40284f3e4177aae4ba480dbb8bcf0a5 Mon Sep 17 00:00:00 2001 From: lorne <1991wangliang@gmail.com> Date: Wed, 1 Apr 2026 17:02:49 +0800 Subject: [PATCH 1/3] fix DynamicTableClassLoader bind bug --- .../example-app/example-app-cmd-domain/pom.xml | 2 +- example/example-app/example-app-cmd-meta/pom.xml | 2 +- example/example-app/example-app-query/pom.xml | 2 +- example/example-app/pom.xml | 2 +- .../example-domain/example-domain-leave/pom.xml | 2 +- .../example-domain/example-domain-user/pom.xml | 2 +- example/example-domain/pom.xml | 2 +- example/example-infra/example-infra-flow/pom.xml | 2 +- example/example-infra/example-infra-jpa/pom.xml | 2 +- .../example-infra/example-infra-security/pom.xml | 2 +- example/example-infra/pom.xml | 2 +- example/example-interface/pom.xml | 2 +- example/example-server/pom.xml | 2 +- .../src/main/resources/application.properties | 16 ++++++++-------- example/pom.xml | 2 +- pom.xml | 2 +- springboot-starter-data-authorization/pom.xml | 2 +- springboot-starter-data-fast/pom.xml | 2 +- .../classloader/DynamicTableClassLoader.java | 3 +++ springboot-starter-flow/pom.xml | 2 +- springboot-starter-security/pom.xml | 2 +- springboot-starter/pom.xml | 2 +- 22 files changed, 31 insertions(+), 28 deletions(-) diff --git a/example/example-app/example-app-cmd-domain/pom.xml b/example/example-app/example-app-cmd-domain/pom.xml index 240ac68d..f3bdeeba 100644 --- a/example/example-app/example-app-cmd-domain/pom.xml +++ b/example/example-app/example-app-cmd-domain/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-app - 3.4.39 + 3.4.40 ../pom.xml diff --git a/example/example-app/example-app-cmd-meta/pom.xml b/example/example-app/example-app-cmd-meta/pom.xml index 2f3193b1..726faf2c 100644 --- a/example/example-app/example-app-cmd-meta/pom.xml +++ b/example/example-app/example-app-cmd-meta/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-app - 3.4.39 + 3.4.40 ../pom.xml diff --git a/example/example-app/example-app-query/pom.xml b/example/example-app/example-app-query/pom.xml index c02f3e24..cb126b08 100644 --- a/example/example-app/example-app-query/pom.xml +++ b/example/example-app/example-app-query/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-app - 3.4.39 + 3.4.40 ../pom.xml diff --git a/example/example-app/pom.xml b/example/example-app/pom.xml index 3cae6d2a..7ca3345f 100644 --- a/example/example-app/pom.xml +++ b/example/example-app/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot springboot-example - 3.4.39 + 3.4.40 ../pom.xml pom diff --git a/example/example-domain/example-domain-leave/pom.xml b/example/example-domain/example-domain-leave/pom.xml index 16003c0a..256d3dac 100644 --- a/example/example-domain/example-domain-leave/pom.xml +++ b/example/example-domain/example-domain-leave/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-domain - 3.4.39 + 3.4.40 ../pom.xml diff --git a/example/example-domain/example-domain-user/pom.xml b/example/example-domain/example-domain-user/pom.xml index 2c024ab6..4024983f 100644 --- a/example/example-domain/example-domain-user/pom.xml +++ b/example/example-domain/example-domain-user/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-domain - 3.4.39 + 3.4.40 ../pom.xml diff --git a/example/example-domain/pom.xml b/example/example-domain/pom.xml index 4145fdd6..773375c0 100644 --- a/example/example-domain/pom.xml +++ b/example/example-domain/pom.xml @@ -5,7 +5,7 @@ com.codingapi.springboot springboot-example - 3.4.39 + 3.4.40 ../pom.xml 4.0.0 diff --git a/example/example-infra/example-infra-flow/pom.xml b/example/example-infra/example-infra-flow/pom.xml index e2b24698..2574c822 100644 --- a/example/example-infra/example-infra-flow/pom.xml +++ b/example/example-infra/example-infra-flow/pom.xml @@ -5,7 +5,7 @@ com.codingapi.springboot example-infra - 3.4.39 + 3.4.40 ../pom.xml diff --git a/example/example-infra/example-infra-jpa/pom.xml b/example/example-infra/example-infra-jpa/pom.xml index 7d98b344..5b044875 100644 --- a/example/example-infra/example-infra-jpa/pom.xml +++ b/example/example-infra/example-infra-jpa/pom.xml @@ -5,7 +5,7 @@ com.codingapi.springboot example-infra - 3.4.39 + 3.4.40 ../pom.xml diff --git a/example/example-infra/example-infra-security/pom.xml b/example/example-infra/example-infra-security/pom.xml index f8205d84..c9036788 100644 --- a/example/example-infra/example-infra-security/pom.xml +++ b/example/example-infra/example-infra-security/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-infra - 3.4.39 + 3.4.40 ../pom.xml diff --git a/example/example-infra/pom.xml b/example/example-infra/pom.xml index fee8b269..ad4065ac 100644 --- a/example/example-infra/pom.xml +++ b/example/example-infra/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot springboot-example - 3.4.39 + 3.4.40 ../pom.xml pom diff --git a/example/example-interface/pom.xml b/example/example-interface/pom.xml index a73049c6..87bdffa7 100644 --- a/example/example-interface/pom.xml +++ b/example/example-interface/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot springboot-example - 3.4.39 + 3.4.40 example-interface diff --git a/example/example-server/pom.xml b/example/example-server/pom.xml index 4ef599ce..432cc344 100644 --- a/example/example-server/pom.xml +++ b/example/example-server/pom.xml @@ -5,7 +5,7 @@ springboot-example com.codingapi.springboot - 3.4.39 + 3.4.40 4.0.0 diff --git a/example/example-server/src/main/resources/application.properties b/example/example-server/src/main/resources/application.properties index 35a250d8..7f97bcb2 100644 --- a/example/example-server/src/main/resources/application.properties +++ b/example/example-server/src/main/resources/application.properties @@ -1,16 +1,16 @@ server.port=8090 application.version=@project.version@ -#spring.datasource.driver-class-name=org.h2.Driver -#spring.datasource.url=jdbc:h2:file:./example.db -#spring.jpa.database-platform=org.hibernate.dialect.H2Dialect +spring.datasource.driver-class-name=org.h2.Driver +spring.datasource.url=jdbc:h2:file:./example.db +spring.jpa.database-platform=org.hibernate.dialect.H2Dialect -spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver -spring.datasource.url=jdbc:mysql://localhost:3306/flow?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true -spring.datasource.username=root -spring.datasource.password=12345678 -spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect +#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +#spring.datasource.url=jdbc:mysql://localhost:3306/flow?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true +#spring.datasource.username=root +#spring.datasource.password=12345678 +#spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect spring.jpa.hibernate.ddl-auto=update spring.jpa.show-sql=true diff --git a/example/pom.xml b/example/pom.xml index 900d3c89..69deea0c 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -19,7 +19,7 @@ springboot-example - 3.4.39 + 3.4.40 springboot-example springboot-example project for Spring Boot diff --git a/pom.xml b/pom.xml index 03dcef18..0feb8a44 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ com.codingapi.springboot springboot-parent - 3.4.39 + 3.4.40 https://github.com/codingapi/springboot-framewrok springboot-parent diff --git a/springboot-starter-data-authorization/pom.xml b/springboot-starter-data-authorization/pom.xml index d85a4c11..f1556395 100644 --- a/springboot-starter-data-authorization/pom.xml +++ b/springboot-starter-data-authorization/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot springboot-parent - 3.4.39 + 3.4.40 springboot-starter-data-authorization diff --git a/springboot-starter-data-fast/pom.xml b/springboot-starter-data-fast/pom.xml index 5f3b737f..5a0cab5a 100644 --- a/springboot-starter-data-fast/pom.xml +++ b/springboot-starter-data-fast/pom.xml @@ -5,7 +5,7 @@ springboot-parent com.codingapi.springboot - 3.4.39 + 3.4.40 4.0.0 diff --git a/springboot-starter-data-fast/src/main/java/com/codingapi/springboot/fast/classloader/DynamicTableClassLoader.java b/springboot-starter-data-fast/src/main/java/com/codingapi/springboot/fast/classloader/DynamicTableClassLoader.java index cf182bf2..243634e6 100644 --- a/springboot-starter-data-fast/src/main/java/com/codingapi/springboot/fast/classloader/DynamicTableClassLoader.java +++ b/springboot-starter-data-fast/src/main/java/com/codingapi/springboot/fast/classloader/DynamicTableClassLoader.java @@ -31,6 +31,7 @@ private DynamicTableClassLoader() { */ public void registerClass(String className, Class clazz) { dynamicTableClassLoader.registerClass(className, clazz); + Thread.currentThread().setContextClassLoader(dynamicTableClassLoader); } /** @@ -39,6 +40,7 @@ public void registerClass(String className, Class clazz) { */ public void registerClass(Class clazz) { dynamicTableClassLoader.registerClass(clazz); + Thread.currentThread().setContextClassLoader(dynamicTableClassLoader); } /** @@ -66,6 +68,7 @@ public Class loadClass(String name, boolean resolve) throws ClassNotFoundExce */ public void cleanDynamicClass(String name) { dynamicTableClassLoader.cleanClass(name); + Thread.currentThread().setContextClassLoader(dynamicTableClassLoader); } /** diff --git a/springboot-starter-flow/pom.xml b/springboot-starter-flow/pom.xml index d4e2890d..664d4cc4 100644 --- a/springboot-starter-flow/pom.xml +++ b/springboot-starter-flow/pom.xml @@ -6,7 +6,7 @@ springboot-parent com.codingapi.springboot - 3.4.39 + 3.4.40 springboot-starter-flow diff --git a/springboot-starter-security/pom.xml b/springboot-starter-security/pom.xml index bbdd5daf..0cb7837e 100644 --- a/springboot-starter-security/pom.xml +++ b/springboot-starter-security/pom.xml @@ -6,7 +6,7 @@ springboot-parent com.codingapi.springboot - 3.4.39 + 3.4.40 springboot-starter-security diff --git a/springboot-starter/pom.xml b/springboot-starter/pom.xml index 6b32c5ad..0fb77a87 100644 --- a/springboot-starter/pom.xml +++ b/springboot-starter/pom.xml @@ -5,7 +5,7 @@ com.codingapi.springboot springboot-parent - 3.4.39 + 3.4.40 springboot-starter From a207381e847fd1bc1c2f8461b0f639acdf62310a Mon Sep 17 00:00:00 2001 From: lorne <1991wangliang@gmail.com> Date: Fri, 24 Apr 2026 15:20:39 +0800 Subject: [PATCH 2/3] add annotationClasses --- .../example-app-cmd-domain/pom.xml | 2 +- .../example-app/example-app-cmd-meta/pom.xml | 2 +- example/example-app/example-app-query/pom.xml | 2 +- example/example-app/pom.xml | 2 +- .../example-domain-leave/pom.xml | 2 +- .../example-domain-user/pom.xml | 2 +- example/example-domain/pom.xml | 2 +- .../example-infra/example-infra-flow/pom.xml | 2 +- .../example-infra/example-infra-jpa/pom.xml | 2 +- .../example-infra-security/pom.xml | 2 +- example/example-infra/pom.xml | 2 +- example/example-interface/pom.xml | 2 +- example/example-server/pom.xml | 2 +- example/pom.xml | 2 +- pom.xml | 2 +- springboot-starter-data-authorization/pom.xml | 2 +- springboot-starter-data-fast/pom.xml | 2 +- .../fast/jpa/JpaQueryContextRegister.java | 2 +- .../metadata/TableEntityClassBuilder.java | 7 +++++ .../fast/metadata/TableEntityMetadata.java | 31 +++++++++++++++---- .../springboot/fast/TestRepositoryTest.java | 25 +++++++++++++++ .../fast/annotation/MyIdSequence.java | 18 +++++++++++ .../springboot/fast/entity/Test.java | 18 +++++++++++ .../generator/DynamicTableGeneratorTest.java | 12 +++---- .../fast/repository/TestRepository.java | 8 +++++ .../fast/strategy/MyIdGenerator.java | 27 ++++++++++++++++ springboot-starter-flow/pom.xml | 2 +- springboot-starter-security/pom.xml | 2 +- springboot-starter/pom.xml | 2 +- 29 files changed, 155 insertions(+), 33 deletions(-) create mode 100644 springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/TestRepositoryTest.java create mode 100644 springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/annotation/MyIdSequence.java create mode 100644 springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/entity/Test.java create mode 100644 springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/repository/TestRepository.java create mode 100644 springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/strategy/MyIdGenerator.java diff --git a/example/example-app/example-app-cmd-domain/pom.xml b/example/example-app/example-app-cmd-domain/pom.xml index f3bdeeba..3ec2c103 100644 --- a/example/example-app/example-app-cmd-domain/pom.xml +++ b/example/example-app/example-app-cmd-domain/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-app - 3.4.40 + 3.4.41 ../pom.xml diff --git a/example/example-app/example-app-cmd-meta/pom.xml b/example/example-app/example-app-cmd-meta/pom.xml index 726faf2c..93978462 100644 --- a/example/example-app/example-app-cmd-meta/pom.xml +++ b/example/example-app/example-app-cmd-meta/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-app - 3.4.40 + 3.4.41 ../pom.xml diff --git a/example/example-app/example-app-query/pom.xml b/example/example-app/example-app-query/pom.xml index cb126b08..d0d0b8f8 100644 --- a/example/example-app/example-app-query/pom.xml +++ b/example/example-app/example-app-query/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-app - 3.4.40 + 3.4.41 ../pom.xml diff --git a/example/example-app/pom.xml b/example/example-app/pom.xml index 7ca3345f..2558b77b 100644 --- a/example/example-app/pom.xml +++ b/example/example-app/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot springboot-example - 3.4.40 + 3.4.41 ../pom.xml pom diff --git a/example/example-domain/example-domain-leave/pom.xml b/example/example-domain/example-domain-leave/pom.xml index 256d3dac..46bef0fc 100644 --- a/example/example-domain/example-domain-leave/pom.xml +++ b/example/example-domain/example-domain-leave/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-domain - 3.4.40 + 3.4.41 ../pom.xml diff --git a/example/example-domain/example-domain-user/pom.xml b/example/example-domain/example-domain-user/pom.xml index 4024983f..5723c837 100644 --- a/example/example-domain/example-domain-user/pom.xml +++ b/example/example-domain/example-domain-user/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-domain - 3.4.40 + 3.4.41 ../pom.xml diff --git a/example/example-domain/pom.xml b/example/example-domain/pom.xml index 773375c0..09986be1 100644 --- a/example/example-domain/pom.xml +++ b/example/example-domain/pom.xml @@ -5,7 +5,7 @@ com.codingapi.springboot springboot-example - 3.4.40 + 3.4.41 ../pom.xml 4.0.0 diff --git a/example/example-infra/example-infra-flow/pom.xml b/example/example-infra/example-infra-flow/pom.xml index 2574c822..79b8f020 100644 --- a/example/example-infra/example-infra-flow/pom.xml +++ b/example/example-infra/example-infra-flow/pom.xml @@ -5,7 +5,7 @@ com.codingapi.springboot example-infra - 3.4.40 + 3.4.41 ../pom.xml diff --git a/example/example-infra/example-infra-jpa/pom.xml b/example/example-infra/example-infra-jpa/pom.xml index 5b044875..a1a63ffa 100644 --- a/example/example-infra/example-infra-jpa/pom.xml +++ b/example/example-infra/example-infra-jpa/pom.xml @@ -5,7 +5,7 @@ com.codingapi.springboot example-infra - 3.4.40 + 3.4.41 ../pom.xml diff --git a/example/example-infra/example-infra-security/pom.xml b/example/example-infra/example-infra-security/pom.xml index c9036788..6def65b6 100644 --- a/example/example-infra/example-infra-security/pom.xml +++ b/example/example-infra/example-infra-security/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-infra - 3.4.40 + 3.4.41 ../pom.xml diff --git a/example/example-infra/pom.xml b/example/example-infra/pom.xml index ad4065ac..d93f9d96 100644 --- a/example/example-infra/pom.xml +++ b/example/example-infra/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot springboot-example - 3.4.40 + 3.4.41 ../pom.xml pom diff --git a/example/example-interface/pom.xml b/example/example-interface/pom.xml index 87bdffa7..2091fffb 100644 --- a/example/example-interface/pom.xml +++ b/example/example-interface/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot springboot-example - 3.4.40 + 3.4.41 example-interface diff --git a/example/example-server/pom.xml b/example/example-server/pom.xml index 432cc344..6490bac0 100644 --- a/example/example-server/pom.xml +++ b/example/example-server/pom.xml @@ -5,7 +5,7 @@ springboot-example com.codingapi.springboot - 3.4.40 + 3.4.41 4.0.0 diff --git a/example/pom.xml b/example/pom.xml index 69deea0c..0fa5ea5c 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -19,7 +19,7 @@ springboot-example - 3.4.40 + 3.4.41 springboot-example springboot-example project for Spring Boot diff --git a/pom.xml b/pom.xml index 0feb8a44..0f576a03 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ com.codingapi.springboot springboot-parent - 3.4.40 + 3.4.41 https://github.com/codingapi/springboot-framewrok springboot-parent diff --git a/springboot-starter-data-authorization/pom.xml b/springboot-starter-data-authorization/pom.xml index f1556395..ad44651e 100644 --- a/springboot-starter-data-authorization/pom.xml +++ b/springboot-starter-data-authorization/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot springboot-parent - 3.4.40 + 3.4.41 springboot-starter-data-authorization diff --git a/springboot-starter-data-fast/pom.xml b/springboot-starter-data-fast/pom.xml index 5a0cab5a..adab3cac 100644 --- a/springboot-starter-data-fast/pom.xml +++ b/springboot-starter-data-fast/pom.xml @@ -5,7 +5,7 @@ springboot-parent com.codingapi.springboot - 3.4.40 + 3.4.41 4.0.0 diff --git a/springboot-starter-data-fast/src/main/java/com/codingapi/springboot/fast/jpa/JpaQueryContextRegister.java b/springboot-starter-data-fast/src/main/java/com/codingapi/springboot/fast/jpa/JpaQueryContextRegister.java index 1d765f9d..a00717ef 100644 --- a/springboot-starter-data-fast/src/main/java/com/codingapi/springboot/fast/jpa/JpaQueryContextRegister.java +++ b/springboot-starter-data-fast/src/main/java/com/codingapi/springboot/fast/jpa/JpaQueryContextRegister.java @@ -6,7 +6,7 @@ @AllArgsConstructor public class JpaQueryContextRegister implements InitializingBean { - private JpaQuery jpaQuery; + private final JpaQuery jpaQuery; @Override public void afterPropertiesSet() throws Exception { diff --git a/springboot-starter-data-fast/src/main/java/com/codingapi/springboot/fast/metadata/TableEntityClassBuilder.java b/springboot-starter-data-fast/src/main/java/com/codingapi/springboot/fast/metadata/TableEntityClassBuilder.java index aa28ec97..99bc9c4d 100644 --- a/springboot-starter-data-fast/src/main/java/com/codingapi/springboot/fast/metadata/TableEntityClassBuilder.java +++ b/springboot-starter-data-fast/src/main/java/com/codingapi/springboot/fast/metadata/TableEntityClassBuilder.java @@ -12,6 +12,7 @@ import org.springframework.util.StringUtils; import java.io.Serializable; +import java.lang.annotation.Annotation; import java.util.ArrayList; import java.util.List; @@ -146,6 +147,12 @@ private List buildFieldAnnotations( TableEntityMetadata.ColumnMeta columnMeta) { List annotations = new ArrayList<>(); + if (columnMeta.getAnnotationClasses() != null) { + for(Class annotaionClass: columnMeta.getAnnotationClasses()) { + annotations.add(AnnotationDescription.Builder.ofType(annotaionClass).build()); + } + } + // @Id 注解 if (columnMeta.isPrimaryKey()) { annotations.add(AnnotationDescription.Builder.ofType(Id.class).build()); diff --git a/springboot-starter-data-fast/src/main/java/com/codingapi/springboot/fast/metadata/TableEntityMetadata.java b/springboot-starter-data-fast/src/main/java/com/codingapi/springboot/fast/metadata/TableEntityMetadata.java index d3b9154f..ea7576c3 100644 --- a/springboot-starter-data-fast/src/main/java/com/codingapi/springboot/fast/metadata/TableEntityMetadata.java +++ b/springboot-starter-data-fast/src/main/java/com/codingapi/springboot/fast/metadata/TableEntityMetadata.java @@ -4,8 +4,10 @@ import lombok.Getter; import lombok.Setter; +import java.lang.annotation.Annotation; import java.util.ArrayList; import java.util.List; +import java.util.Set; /** * 表实体元数据 @@ -64,6 +66,10 @@ public static class ColumnMeta { * 主键自增策略 */ private GeneratedValueMeta generatedValue; + /** + * 字段注解 + */ + private Set> annotationClasses; /** * 备注 */ @@ -149,8 +155,12 @@ public void setTable(String name) { this.setTable(name, null, null, null); } + public void addColumn(ColumnMeta column) { + this.columns.add(column); + } + public void addPrimaryKeyColumn(Class type, String fieldName, String columnName, GenerationType strategy, - String generator, String comment, boolean isLob, boolean unique, boolean nullable, + String generator, Set> annotationClasses, String comment, boolean isLob, boolean unique, boolean nullable, boolean insertable, boolean updatable, String columnDefinition, int length, int precision, int scale) { ColumnMeta column = new ColumnMeta(); @@ -161,6 +171,7 @@ public void addPrimaryKeyColumn(Class type, String fieldName, String columnNa GeneratedValueMeta generatedValueMeta = new GeneratedValueMeta(); generatedValueMeta.setGenerator(generator); generatedValueMeta.setStrategy(strategy); + column.setAnnotationClasses(annotationClasses); column.setGeneratedValue(generatedValueMeta); column.setLob(isLob); column.setComment(comment); @@ -172,7 +183,7 @@ public void addPrimaryKeyColumn(Class type, String fieldName, String columnNa column.setLength(length); column.setPrecision(precision); column.setScale(scale); - this.columns.add(column); + this.addColumn(column); } public void addColumn(Class type, String fieldName, String columnName, String comment, boolean isLob, @@ -194,7 +205,7 @@ public void addColumn(Class type, String fieldName, String columnName, String column.setLength(length); column.setPrecision(precision); column.setScale(scale); - this.columns.add(column); + this.addColumn(column); } public void addColumn(Class type, String name, String comment) { @@ -214,15 +225,23 @@ public void addColumn(Class type, String name) { } public void addPrimaryKeyColumn(Class type, String name) { - this.addPrimaryKeyColumn(type, name, name, null, null, null, false, false, false, false, false, null, 255, 0, 0); + this.addPrimaryKeyColumn(type, name, name, null, null, null, null, false, false, false, false, false, null, 255, 0, 0); + } + + public void addPrimaryKeyColumn(Class type, String name, String comment) { + this.addPrimaryKeyColumn(type, name, name, null, null, null, comment, false, false, false, false, false, null, 255, 0, 0); } public void addPrimaryKeyColumn(Class type, String name, GenerationType strategy) { - this.addPrimaryKeyColumn(type, name, name, strategy, null, null, false, false, false, false, false, null, 255, 0, 0); + this.addPrimaryKeyColumn(type, name, name, strategy, null, null, null, false, false, false, false, false, null, 255, 0, 0); } public void addPrimaryKeyColumn(Class type, String name, GenerationType strategy, String comment) { - this.addPrimaryKeyColumn(type, name, name, strategy, null, comment, false, false, false, false, false, null, 255, 0, 0); + this.addPrimaryKeyColumn(type, name, name, strategy, null, null, comment, false, false, false, false, false, null, 255, 0, 0); + } + + public void addPrimaryKeyColumn(Class type, String name, Set> annotationClasses, String comment) { + this.addPrimaryKeyColumn(type, name, name, null, null, annotationClasses, comment, false, false, false, false, false, null, 255, 0, 0); } public void verify() { diff --git a/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/TestRepositoryTest.java b/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/TestRepositoryTest.java new file mode 100644 index 00000000..cb3aa6aa --- /dev/null +++ b/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/TestRepositoryTest.java @@ -0,0 +1,25 @@ +package com.codingapi.springboot.fast; + +import com.codingapi.springboot.fast.repository.TestRepository; +import lombok.extern.slf4j.Slf4j; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +@Slf4j +@SpringBootTest +public class TestRepositoryTest { + + @Autowired + private TestRepository testRepository; + + @Test + void test1() { + com.codingapi.springboot.fast.entity.Test demo = new com.codingapi.springboot.fast.entity.Test(); + demo.setName("123"); + testRepository.save(demo); + } + + + +} diff --git a/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/annotation/MyIdSequence.java b/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/annotation/MyIdSequence.java new file mode 100644 index 00000000..357e7b1e --- /dev/null +++ b/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/annotation/MyIdSequence.java @@ -0,0 +1,18 @@ +package com.codingapi.springboot.fast.annotation; + +import com.codingapi.springboot.fast.strategy.MyIdGenerator; +import org.hibernate.annotations.IdGeneratorType; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +@IdGeneratorType(MyIdGenerator.class) +@Retention(RUNTIME) +@Target({METHOD,FIELD}) +public @interface MyIdSequence { + +} diff --git a/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/entity/Test.java b/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/entity/Test.java new file mode 100644 index 00000000..72ca5db0 --- /dev/null +++ b/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/entity/Test.java @@ -0,0 +1,18 @@ +package com.codingapi.springboot.fast.entity; + +import com.codingapi.springboot.fast.annotation.MyIdSequence; +import jakarta.persistence.*; +import lombok.Data; + + +@Data +@Entity +@Table(name = "t_test") +public class Test { + + @Id + @MyIdSequence + private Integer id; + + private String name; +} diff --git a/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/generator/DynamicTableGeneratorTest.java b/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/generator/DynamicTableGeneratorTest.java index cb931677..0a2908a5 100644 --- a/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/generator/DynamicTableGeneratorTest.java +++ b/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/generator/DynamicTableGeneratorTest.java @@ -8,13 +8,13 @@ import java.util.List; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertNotNull; class DynamicTableGeneratorTest { @Test void generateTableDDL() { - DynamicTableGenerator dynamicTableGenerator = new DynamicTableGenerator(H2Dialect.class,"jdbc:h2:file:./test.db"); + DynamicTableGenerator dynamicTableGenerator = new DynamicTableGenerator(H2Dialect.class, "jdbc:h2:file:./test.db"); List exceptions = dynamicTableGenerator.validatorTable(Demo.class); System.out.println(exceptions); @@ -33,13 +33,13 @@ void generateTableDDL() { @Test void dynamicGenerateTableDDL() { - DynamicTableGenerator dynamicTableGenerator = new DynamicTableGenerator(H2Dialect.class,"jdbc:h2:file:./test.db"); + DynamicTableGenerator dynamicTableGenerator = new DynamicTableGenerator(H2Dialect.class, "jdbc:h2:file:./test.db"); TableEntityMetadata tableEntityMetadata = new TableEntityMetadata("com.codingapi.entity.Test"); tableEntityMetadata.setTable("test"); - tableEntityMetadata.addPrimaryKeyColumn(Long.class,"id", GenerationType.IDENTITY,"主键"); - tableEntityMetadata.addColumn(String.class,"name","姓名"); - tableEntityMetadata.addColumn(String.class,"desc","描述",true); + tableEntityMetadata.addPrimaryKeyColumn(Long.class, "id", GenerationType.IDENTITY, "主键"); + tableEntityMetadata.addColumn(String.class, "name", "姓名"); + tableEntityMetadata.addColumn(String.class, "desc", "描述", true); Class entityClass = tableEntityMetadata.buildClass(); diff --git a/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/repository/TestRepository.java b/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/repository/TestRepository.java new file mode 100644 index 00000000..63094cd8 --- /dev/null +++ b/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/repository/TestRepository.java @@ -0,0 +1,8 @@ +package com.codingapi.springboot.fast.repository; + +import com.codingapi.springboot.fast.entity.Test; +import com.codingapi.springboot.fast.jpa.repository.FastRepository; + +public interface TestRepository extends FastRepository { + +} diff --git a/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/strategy/MyIdGenerator.java b/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/strategy/MyIdGenerator.java new file mode 100644 index 00000000..c1dd478d --- /dev/null +++ b/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/strategy/MyIdGenerator.java @@ -0,0 +1,27 @@ +package com.codingapi.springboot.fast.strategy; + +import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.generator.BeforeExecutionGenerator; +import org.hibernate.generator.EventType; + +import java.util.EnumSet; +import java.util.Random; + +import static org.hibernate.generator.EventTypeSets.INSERT_ONLY; + +public class MyIdGenerator implements BeforeExecutionGenerator { + + private final Random random = new Random(); + + @Override + public Object generate(SharedSessionContractImplementor session, Object owner, Object currentValue, EventType eventType) { + int id = random.nextInt(1000); + System.out.println("id:"+id); + return id; + } + + @Override + public EnumSet getEventTypes() { + return INSERT_ONLY; + } +} diff --git a/springboot-starter-flow/pom.xml b/springboot-starter-flow/pom.xml index 664d4cc4..c8dade09 100644 --- a/springboot-starter-flow/pom.xml +++ b/springboot-starter-flow/pom.xml @@ -6,7 +6,7 @@ springboot-parent com.codingapi.springboot - 3.4.40 + 3.4.41 springboot-starter-flow diff --git a/springboot-starter-security/pom.xml b/springboot-starter-security/pom.xml index 0cb7837e..fa93fb1f 100644 --- a/springboot-starter-security/pom.xml +++ b/springboot-starter-security/pom.xml @@ -6,7 +6,7 @@ springboot-parent com.codingapi.springboot - 3.4.40 + 3.4.41 springboot-starter-security diff --git a/springboot-starter/pom.xml b/springboot-starter/pom.xml index 0fb77a87..2df5657f 100644 --- a/springboot-starter/pom.xml +++ b/springboot-starter/pom.xml @@ -5,7 +5,7 @@ com.codingapi.springboot springboot-parent - 3.4.40 + 3.4.41 springboot-starter From 62076ecf12d7781653ad7b2f298112973baf378a Mon Sep 17 00:00:00 2001 From: lorne <1991wangliang@gmail.com> Date: Fri, 24 Apr 2026 15:30:52 +0800 Subject: [PATCH 3/3] add annotationClasses --- ...epositoryTest.java => MyTestRepositoryTest.java} | 13 +++++++------ .../fast/entity/{Test.java => MyTest.java} | 2 +- .../fast/repository/MyTestRepository.java | 8 ++++++++ .../springboot/fast/repository/TestRepository.java | 8 -------- 4 files changed, 16 insertions(+), 15 deletions(-) rename springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/{TestRepositoryTest.java => MyTestRepositoryTest.java} (51%) rename springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/entity/{Test.java => MyTest.java} (92%) create mode 100644 springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/repository/MyTestRepository.java delete mode 100644 springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/repository/TestRepository.java diff --git a/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/TestRepositoryTest.java b/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/MyTestRepositoryTest.java similarity index 51% rename from springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/TestRepositoryTest.java rename to springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/MyTestRepositoryTest.java index cb3aa6aa..19a9e1e4 100644 --- a/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/TestRepositoryTest.java +++ b/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/MyTestRepositoryTest.java @@ -1,6 +1,7 @@ package com.codingapi.springboot.fast; -import com.codingapi.springboot.fast.repository.TestRepository; +import com.codingapi.springboot.fast.entity.MyTest; +import com.codingapi.springboot.fast.repository.MyTestRepository; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -8,16 +9,16 @@ @Slf4j @SpringBootTest -public class TestRepositoryTest { +public class MyTestRepositoryTest { @Autowired - private TestRepository testRepository; + private MyTestRepository myTestRepository; @Test - void test1() { - com.codingapi.springboot.fast.entity.Test demo = new com.codingapi.springboot.fast.entity.Test(); + void test() { + MyTest demo = new MyTest(); demo.setName("123"); - testRepository.save(demo); + myTestRepository.save(demo); } diff --git a/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/entity/Test.java b/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/entity/MyTest.java similarity index 92% rename from springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/entity/Test.java rename to springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/entity/MyTest.java index 72ca5db0..ed8f2eed 100644 --- a/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/entity/Test.java +++ b/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/entity/MyTest.java @@ -8,7 +8,7 @@ @Data @Entity @Table(name = "t_test") -public class Test { +public class MyTest { @Id @MyIdSequence diff --git a/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/repository/MyTestRepository.java b/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/repository/MyTestRepository.java new file mode 100644 index 00000000..44c42c81 --- /dev/null +++ b/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/repository/MyTestRepository.java @@ -0,0 +1,8 @@ +package com.codingapi.springboot.fast.repository; + +import com.codingapi.springboot.fast.entity.MyTest; +import com.codingapi.springboot.fast.jpa.repository.FastRepository; + +public interface MyTestRepository extends FastRepository { + +} diff --git a/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/repository/TestRepository.java b/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/repository/TestRepository.java deleted file mode 100644 index 63094cd8..00000000 --- a/springboot-starter-data-fast/src/test/java/com/codingapi/springboot/fast/repository/TestRepository.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.codingapi.springboot.fast.repository; - -import com.codingapi.springboot.fast.entity.Test; -import com.codingapi.springboot.fast.jpa.repository.FastRepository; - -public interface TestRepository extends FastRepository { - -}