데이터 클래스 이름없는 ColumnInfo 수정

master
mjkhan21 1 year ago
parent 14178d7a8a
commit 9b9e0dbfbc

@ -1,5 +1,7 @@
package cokr.xit.tool.codegen.table; package cokr.xit.tool.codegen.table;
import cokr.xit.foundation.Assert;
/** /**
* @author mjkhan * @author mjkhan
*/ */
@ -53,6 +55,10 @@ public class ColumnInfo {
return className; return className;
} }
public boolean hasClassName() {
return !Assert.isEmpty(className);
}
public ColumnInfo setClassName(String className) { public ColumnInfo setClassName(String className) {
this.className = className; this.className = className;
return this; return this;

@ -1,6 +1,7 @@
package cokr.xit.tool.codegen.table; package cokr.xit.tool.codegen.table;
import java.util.Collections; import java.util.Collections;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -39,6 +40,15 @@ public class TableInfo {
return this; return this;
} }
public TableInfo removeClassNotFound() {
List<String> notFounds = columns.entrySet().stream()
.filter(entry -> !entry.getValue().hasClassName())
.map(entry -> entry.getKey())
.toList();
notFounds.forEach(key -> columns.remove(key));
return this;
}
@Override @Override
public String toString() { public String toString() {
return String.format("Table(%s, %s)", name, comment); return String.format("Table(%s, %s)", name, comment);

@ -36,7 +36,8 @@ public class TableInfoFactory {
private TableInfo getTable(String tableName, DatabaseMetaData metadata) throws Exception { private TableInfo getTable(String tableName, DatabaseMetaData metadata) throws Exception {
try (ResultSet resultSet = metadata.getTables(null, null, tableName, null);) { try (ResultSet resultSet = metadata.getTables(null, null, tableName, null);) {
while (resultSet.next()) { while (resultSet.next()) {
TableInfo table = new TableInfo().setName(tableName); TableInfo table = new TableInfo()
.setName(tableName);
table.setComment(resultSet.getString("REMARKS")); table.setComment(resultSet.getString("REMARKS"));
return table; return table;
} }
@ -94,7 +95,7 @@ public class TableInfoFactory {
String className = metadata.getColumnClassName(i); String className = metadata.getColumnClassName(i);
table.getColumns().get(columnName).setClassName(className); table.getColumns().get(columnName).setClassName(className);
} }
table.removeClassNotFound();
} }
} }
} }
Loading…
Cancel
Save