Browse Source

优化autoddl

zhou-hao 4 years ago
parent
commit
2337e55929

+ 0 - 4
hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/configuration/AutoDDLProcessor.java

@@ -55,11 +55,7 @@ public class AutoDDLProcessor implements InitializingBean {
             }
         }
         List<Class> entities = this.entities.stream().map(EntityInfo::getRealType).collect(Collectors.toList());
-
         if (properties.isAutoDdl()) {
-            operator.getMetadata()
-                    .getCurrentSchema()
-                    .loadAllTable();
             //加载全部表信息
 //            if (reactive) {
 //                Flux.fromIterable(entities)

+ 11 - 5
hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/configuration/EasyormConfiguration.java

@@ -12,6 +12,7 @@ import org.hswebframework.ezorm.rdb.mapping.MappingFeatureType;
 import org.hswebframework.ezorm.rdb.mapping.jpa.JpaEntityTableMetadataParser;
 import org.hswebframework.ezorm.rdb.mapping.parser.EntityTableMetadataParser;
 import org.hswebframework.ezorm.rdb.metadata.RDBDatabaseMetadata;
+import org.hswebframework.ezorm.rdb.metadata.RDBSchemaMetadata;
 import org.hswebframework.ezorm.rdb.operator.DatabaseOperator;
 import org.hswebframework.ezorm.rdb.operator.DefaultDatabaseOperator;
 import org.hswebframework.web.api.crud.entity.EntityFactory;
@@ -47,6 +48,7 @@ public class EasyormConfiguration {
     static {
 
     }
+
     @Bean
     @ConditionalOnMissingBean
     public EntityFactory entityFactory() {
@@ -67,9 +69,9 @@ public class EasyormConfiguration {
             public EntityColumnMapping getMapping(Class entity) {
 
                 return resolver.resolve(entityFactory.getInstanceType(entity, true))
-                        .getFeature(MappingFeatureType.columnPropertyMapping.createFeatureId(entity))
-                        .map(EntityColumnMapping.class::cast)
-                        .orElse(null);
+                               .getFeature(MappingFeatureType.columnPropertyMapping.createFeatureId(entity))
+                               .map(EntityColumnMapping.class::cast)
+                               .orElse(null);
             }
         };
     }
@@ -104,7 +106,11 @@ public class EasyormConfiguration {
         RDBDatabaseMetadata metadata = properties.createDatabaseMetadata();
         syncSqlExecutor.ifPresent(metadata::addFeature);
         reactiveSqlExecutor.ifPresent(metadata::addFeature);
-
+        if (properties.isAutoDdl()) {
+            for (RDBSchemaMetadata schema : metadata.getSchemas()) {
+                schema.loadAllTable();
+            }
+        }
         return metadata;
     }
 
@@ -135,7 +141,7 @@ public class EasyormConfiguration {
     }
 
     @Bean
-    public EntityEventListener entityEventListener(){
+    public EntityEventListener entityEventListener() {
         return new EntityEventListener();
     }