throw new IllegalArgumentException(
"The value of an columns cannot be empty.");
}
int columnsCapacity = columns.size();
ObjectBuffered values = new ObjectBuffered(columnsCapacity+1);
StringBuffered sql = new StringBuffered(columnsCapacity+columnsCapacity+columnsCapacity+4)
.append("UPDATE ")
.append(tableName)
.append(" SET ");
/* 处理被更新的字段 */
Iterator columnsIT = columns.entrySet().iterator();
//while(columnsIT.hasNext()){
for(int i=0;i<columnsCapacity;i++){
Map.Entry column = (Map.Entry)columnsIT.next();
Object value = column.getValue();
int valuesSize = values.size();
if(value==null){
sql.append(valuesSize>0?",":"").append(column.getKey()).append("=NULL");
}else{
sql.append(valuesSize>0?",":"").append(column.getKey()).append("=?");
values.append(value);
}
}
/* 处理条件 */
if(condition!=null && condition.size()!=0){
sql.append(" WHERE ").append(condition.getConditionStatement());
values.append(condition.getValueBuffered());
}
return new SQL(SQL.UPDATE, sql, values);
}