码迷,mamicode.com
首页 > 其他好文 > 详细

map操作

时间:2016-04-13 18:35:03      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:

http://blog.csdn.net/liu826710/article/details/9001254

Map<String, Object> oldMap = beanToMap(object);
Map<String, Object> map = new HashMap<String, Object>();

List<String> validateParm = getValidateParm(conn, tableName,config);
for (String stringKey : validateParm) {
if(oldMap.containsKey(stringKey)) {
map.put(stringKey, oldMap.get(stringKey));
}
}

StringBuilder sql = new StringBuilder();
sql.append("UPDATE ");
sql.append(" " + tableName + " ");
sql.append(" SET ");
List<Object> list = new ArrayList<Object>();

Iterator<Entry<String, Object>> it = map.entrySet().iterator();
while (it.hasNext()){
Map.Entry<String, Object> pairs = (Map.Entry<String, Object>)it.next();
sql.append(" " + pairs.getKey() + "=?,");
list.add(pairs.getValue());
}
sql.deleteCharAt(sql.length()-1);
if (sWhere != null && !"".equals(sWhere)) {
sql.append(" ");
sql.append(sWhere);
} else {
sql.append(" where 1=2");
}
QueryRunner queryRunner = new QueryRunner(DATABASE_TYPE_ORACLE.equals(config.getDriverType()));
return queryRunner.update(conn, sql.toString(), list.toArray());

map操作

标签:

原文地址:http://www.cnblogs.com/zshboke-2015/p/5387907.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!