获取更新语句的代码 public static String getUpdateSqlSentence(String tableName, Map mapValueKey, List list) { StringBuffer buffer=new StringBuffer(); if (tableName==null||mapValueKey==null||mapValueKey.size()==0) { return ""; } buff
public static String getUpdateSqlSentence(String tableName, MapmapValueKey, List list) { StringBuffer buffer=new StringBuffer(); if (tableName==null||mapValueKey==null||mapValueKey.size()==0) { return ""; } buffer.append(" update "+tableName+" SET "); for (Map.Entry entry : mapValueKey.entrySet()) { buffer.append(entry.getKey()).append("='").append(entry.getValue()).append("',"); } String sql=buffer.toString().substring(0, buffer.toString().length()-1); String pksString=" where id in ("+getPksMosaicString(list)+")"; sql+=pksString; return sql; } public static String getPksMosaicString(List pks){ if (null==pks||pks.size()==0) { return "''"; }else { StringBuilder builder=new StringBuilder(); for (String pk : pks) { builder.append("'").append(pk).append("'").append(",") ; } return builder.toString().substring(0, builder.toString().length()-1); } }