(Class<?> entityType, String column)
| 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) { |
nothing calls this directly
no test coverage detected