MCPcopy Create free account
hub / github.com/wyouflf/xUtils3 / addColumn

Method addColumn

xutils/src/main/java/org/xutils/db/table/DbBase.java:77–92  ·  view source on GitHub ↗
(Class<?> entityType, String column)

Source from the content-addressed store, hash-verified

75 }
76
77 @Override
78 public void addColumn(Class<?> entityType, String column) throws DbException {
79 TableEntity<?> table = this.getTable(entityType);
80 ColumnEntity col = table.getColumnMap().get(column);
81 if (col != null) {
82 if (!table.tableIsExists()) return; // 不需要添加, 表创建时会自动添加
83 StringBuilder builder = new StringBuilder();
84 builder.append("ALTER TABLE ").append("\"").append(table.getName()).append("\"").
85 append(" ADD COLUMN ").append("\"").append(col.getName()).append("\"").
86 append(" ").append(col.getColumnDbType()).
87 append(" ").append(col.getProperty());
88 execNonQuery(builder.toString());
89 } else {
90 throw new DbException("the column(" + column + ") is not defined in table: " + table.getName());
91 }
92 }
93
94 protected void removeTable(Class<?> entityType) {
95 synchronized (tableMap) {

Callers

nothing calls this directly

Calls 10

getTableMethod · 0.95
getNameMethod · 0.95
getColumnDbTypeMethod · 0.95
getPropertyMethod · 0.95
getColumnMapMethod · 0.80
tableIsExistsMethod · 0.80
getMethod · 0.65
execNonQueryMethod · 0.65
getNameMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected