11package com .codingapi .springboot .fast .classloader ;
22
3- import com .codingapi .springboot .fast .metadata .EntityMeta ;
3+ import com .codingapi .springboot .fast .metadata .EntityMetaData ;
44import jakarta .persistence .*;
55import net .bytebuddy .ByteBuddy ;
66import net .bytebuddy .description .annotation .AnnotationDescription ;
@@ -23,21 +23,21 @@ public class DynamicEntityClassBuilder {
2323 /**
2424 * 根据 EntityClass 构建动态实体
2525 */
26- public static Class <?> buildDynamicEntity (EntityMeta entityMeta ) {
27- if (entityMeta == null || entityMeta .getClassName () == null ) {
26+ public static Class <?> buildDynamicEntity (EntityMetaData entityMetaData ) {
27+ if (entityMetaData == null || entityMetaData .getClassName () == null ) {
2828 throw new IllegalArgumentException ("Entity metadata cannot be null" );
2929 }
3030
3131 try {
3232 DynamicType .Builder <?> builder = new ByteBuddy ()
3333 .subclass (Object .class )
34- .name (entityMeta .getClassName ())
34+ .name (entityMetaData .getClassName ())
3535 .implement (Serializable .class )
36- .annotateType (buildEntityAnnotations (entityMeta ));
36+ .annotateType (buildEntityAnnotations (entityMetaData ));
3737
3838 // 添加字段
3939 boolean hasPrimaryKey = false ;
40- for (EntityMeta .ColumnMeta column : entityMeta .getColumns ()) {
40+ for (EntityMetaData .ColumnMeta column : entityMetaData .getColumns ()) {
4141 builder = addColumnField (builder , column );
4242 if (column .isPrimaryKey ()) {
4343 hasPrimaryKey = true ;
@@ -61,25 +61,25 @@ public static Class<?> buildDynamicEntity(EntityMeta entityMeta) {
6161
6262 } catch (Exception e ) {
6363 throw new RuntimeException ("Failed to build dynamic entity: " +
64- entityMeta .getClassName (), e );
64+ entityMetaData .getClassName (), e );
6565 }
6666 }
6767
6868 /**
6969 * 构建实体类注解
7070 */
71- private static AnnotationDescription [] buildEntityAnnotations (EntityMeta entityMeta ) {
71+ private static AnnotationDescription [] buildEntityAnnotations (EntityMetaData entityMetaData ) {
7272 List <AnnotationDescription > annotations = new ArrayList <>();
7373
7474 // @Entity 注解
7575 annotations .add (AnnotationDescription .Builder .ofType (Entity .class ).build ());
7676
7777 // @Table 注解
78- if (entityMeta .getTable () != null ) {
78+ if (entityMetaData .getTable () != null ) {
7979 AnnotationDescription .Builder tableBuilder =
8080 AnnotationDescription .Builder .ofType (Table .class );
8181
82- EntityMeta .TableMeta tableMeta = entityMeta .getTable ();
82+ EntityMetaData .TableMeta tableMeta = entityMetaData .getTable ();
8383 if (tableMeta .getName () != null && !tableMeta .getName ().isEmpty ()) {
8484 tableBuilder = tableBuilder .define ("name" , tableMeta .getName ());
8585 }
@@ -94,11 +94,11 @@ private static AnnotationDescription[] buildEntityAnnotations(EntityMeta entityM
9494 }
9595
9696 // @Comment 注解 - 注释应该放在类上,而不是表注解上
97- if (entityMeta .getTable () != null && StringUtils .hasText (entityMeta .getTable ().getComment ())) {
97+ if (entityMetaData .getTable () != null && StringUtils .hasText (entityMetaData .getTable ().getComment ())) {
9898 AnnotationDescription .Builder commentBuilder =
9999 AnnotationDescription .Builder .ofType (Comment .class );
100100
101- EntityMeta .TableMeta tableMeta = entityMeta .getTable ();
101+ EntityMetaData .TableMeta tableMeta = entityMetaData .getTable ();
102102 commentBuilder = commentBuilder .define ("value" , tableMeta .getComment ());
103103 annotations .add (commentBuilder .build ());
104104 }
@@ -110,7 +110,7 @@ private static AnnotationDescription[] buildEntityAnnotations(EntityMeta entityM
110110 * 添加字段
111111 */
112112 private static DynamicType .Builder <?> addColumnField (DynamicType .Builder <?> builder ,
113- EntityMeta .ColumnMeta columnMeta ) {
113+ EntityMetaData .ColumnMeta columnMeta ) {
114114 // 确定字段类型
115115 Class <?> fieldType = columnMeta .getType ();
116116
@@ -160,7 +160,7 @@ private static DynamicType.Builder<?> addColumnField(DynamicType.Builder<?> buil
160160 * 构建字段注解
161161 */
162162 private static List <AnnotationDescription > buildFieldAnnotations (
163- EntityMeta .ColumnMeta columnMeta , String fieldName ) {
163+ EntityMetaData .ColumnMeta columnMeta , String fieldName ) {
164164
165165 List <AnnotationDescription > annotations = new ArrayList <>();
166166
@@ -170,7 +170,7 @@ private static List<AnnotationDescription> buildFieldAnnotations(
170170
171171 // @GeneratedValue 注解
172172 if (columnMeta .getGeneratedValue () != null ) {
173- EntityMeta .GeneratedValueMeta genMeta = columnMeta .getGeneratedValue ();
173+ EntityMetaData .GeneratedValueMeta genMeta = columnMeta .getGeneratedValue ();
174174 AnnotationDescription .Builder genBuilder =
175175 AnnotationDescription .Builder .ofType (GeneratedValue .class );
176176
0 commit comments