1515
1616/**
1717 * @author xuxueli 2018-05-02 21:10:45
18+ * @modify zhengk/moshow 20180913
1819 */
1920public class TableParseUtil {
2021
@@ -106,6 +107,7 @@ public static ClassInfo processTableIntoClassInfo(String tableSql) throws IOExce
106107 // field class
107108 columnLine = columnLine .substring (columnLine .indexOf ("`" )+1 ).trim (); // int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
108109 String fieldClass = Object .class .getSimpleName ();
110+ //2018-9-16 zhengk 补充char/clob/blob/json等类型,如果类型未知,默认为String
109111 if (columnLine .startsWith ("int" ) || columnLine .startsWith ("tinyint" ) || columnLine .startsWith ("smallint" )) {
110112 fieldClass = Integer .TYPE .getSimpleName ();
111113 } else if (columnLine .startsWith ("bigint" )) {
@@ -116,10 +118,13 @@ public static ClassInfo processTableIntoClassInfo(String tableSql) throws IOExce
116118 fieldClass = Double .TYPE .getSimpleName ();
117119 } else if (columnLine .startsWith ("datetime" ) || columnLine .startsWith ("timestamp" )) {
118120 fieldClass = Date .class .getSimpleName ();
119- } else if (columnLine .startsWith ("varchar" ) || columnLine .startsWith ("text" )) {
121+ } else if (columnLine .startsWith ("varchar" ) || columnLine .startsWith ("text" )|| columnLine .startsWith ("char" )
122+ || columnLine .startsWith ("clob" )||columnLine .startsWith ("blob" )||columnLine .startsWith ("json" )) {
120123 fieldClass = String .class .getSimpleName ();
121- } else if (columnLine .startsWith ("decimal" )) {
124+ } else if (columnLine .startsWith ("decimal" )|| columnLine . startsWith ( "number" ) ) {
122125 fieldClass = BigDecimal .class .getSimpleName ();
126+ } else {
127+ fieldClass = String .class .getSimpleName ();
123128 }
124129
125130 // field comment
0 commit comments