diff --git a/README.md b/README.md index e6ed1b2..ea9b876 100644 --- a/README.md +++ b/README.md @@ -35,12 +35,12 @@ https://gitee.com/leo_xi/SpringJbaDemo ``` 1. value 列名,1.7.6+支持自定义列名 2. defaultValue 默认值 - 3. notNull 是否允许为空 - 4. primary 是否是主键 - 5. policy 主键生成策略 + 3. notNull 是否允许为空(默认允许) + 4. primary 是否是主键(默认否) + 5. policy 主键生成策略(默认无) 6. length 长度限制 7. remark 备注 - 8. precision 精度(小于length) + 8. precision 精度(小于length)(默认4) 9. charset (1.5.5+新增)设置表字符编码,默认utf8 10. order (1.7.8+新增)对应表的列的顺序,默认0 ``` diff --git a/src/main/java/xin/xihc/jba/db/DB_MySql_Opera.java b/src/main/java/xin/xihc/jba/db/DB_MySql_Opera.java index 84ae468..e3d711c 100644 --- a/src/main/java/xin/xihc/jba/db/DB_MySql_Opera.java +++ b/src/main/java/xin/xihc/jba/db/DB_MySql_Opera.java @@ -3,6 +3,8 @@ */ package xin.xihc.jba.db; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import xin.xihc.jba.annotation.Column; import xin.xihc.jba.annotation.Index; import xin.xihc.jba.core.JbaTemplate; @@ -42,6 +44,7 @@ public class DB_MySql_Opera implements I_TableOperation { private static final int CHAR_MAX_LENGTH = 64; /** varchar的最长的长度,超过字段类型为text */ private static final int VARCHAR_MAX_LENGTH = 20000; + private static final Logger LOGGER = LoggerFactory.getLogger(DB_MySql_Opera.class); /** java类型- mySQL类型 对应map */ private static Map JAVA_CLASS_TO_MYSQL_FIELDNAME = new HashMap<>(); @@ -122,7 +125,11 @@ public void createTable(TableProperties tbl) { // 初始化数据 if (tbl.getTableBean() instanceof InitDataInterface) { - CompletableFuture.runAsync(() -> ((InitDataInterface) tbl.getTableBean()).doInit(jbaTemplate)); + CompletableFuture.runAsync(() -> ((InitDataInterface) tbl.getTableBean()).doInit(jbaTemplate)) + .exceptionally(ex -> { + LOGGER.error("初始化表[" + tbl.getTableName() + "]数据异常:", ex); + return null; + }); } } @@ -205,8 +212,7 @@ public void updateTable(TableProperties tbl) { sql.append("ALTER TABLE ").append(tbl.getTableName()).append(" "); String after = ""; for (ColumnProperties col : tbl.getColumns().values()) { - Optional find = dbColumnList.stream() - .filter(t -> t.colName().equals(col.colName())) + Optional find = dbColumnList.stream().filter(t -> t.colName().equals(col.colName())) .findFirst(); //存在 if (find.isPresent()) {