|
楼主 |
发表于 2015-10-12 15:31:05
|
显示全部楼层
是在COM.JUSTEP.BAAS.DATA里的UTIL.JAVA里参照SAVEDATA吗
public static void saveData(Connection conn, Table table, String tableName, Collection<String> columns) throws SQLException {
if (columns == null) {
columns = new ArrayList<String>();
columns.addAll(table.getColumnNames());
}
String idColumn = table.getIDColumn();
PreparedStatement newStat = conn.prepareStatement(createNewSQL(table, tableName, columns));
for (Row row : table.getRows(RowState.NEW)) {
int i = 1;
for (String column : columns) {
newStat.setObject(i, row.getValue(column));
i++;
}
newStat.execute();
}
PreparedStatement editStat = conn.prepareStatement(createUpdateSQL(table, tableName, columns));
for (Row row : table.getRows(RowState.EDIT)) {
int i = 1;
for (String column : columns) {
editStat.setObject(i, row.getValue(column));
i++;
}
editStat.setObject(columns.size() + 1, row.isChanged(idColumn) ? row.getOldValue(table.getIDColumn()) : row.getValue(idColumn));
editStat.execute();
}
PreparedStatement deleteStat = conn.prepareStatement(createDeleteSQL(table, tableName));
for (Row row : table.getRows(RowState.DELETE)) {
deleteStat.setObject(1, row.isChanged(idColumn) ? row.getOldValue(table.getIDColumn()) : row.getValue(idColumn));
deleteStat.execute();
}
}
|
|