public void forDbUpdate(String tableName, String[] pKeys, Object[] ids, Record record, StringBuilder sql, List<Object> paras) { tableName = tableName.trim(); trimPrimaryKeys(pKeys); sql.append("update ").append(tableName).append(" set "); for (Entry<String, Object> e: record.getColumns().entrySet()) { String colName = e.getKey(); if (!isPrimaryKey(colName, pKeys)) { if (paras.size() > 0) { sql.append(", "); } sql.append(colName).append(" = ? "); paras.add(e.getValue()); } } sql.append(" where "); for (int i=0; i<pKeys.length; i++) { if (i > 0) { sql.append(" and "); } sql.append(pKeys[i]).append(" = ?"); paras.add(ids[i]); } }
public void forModelUpdate(Table table, Map<String, Object> attrs, Set<String> modifyFlag, StringBuilder sql, List<Object> paras) { sql.append("update ").append(table.getName()).append(" set "); String[] pKeys = table.getPrimaryKey(); for (Entry<String, Object> e : attrs.entrySet()) { String colName = e.getKey(); if (modifyFlag.contains(colName) && !isPrimaryKey(colName, pKeys) && table.hasColumnLabel(colName)) { if (paras.size() > 0) { sql.append(", "); } sql.append(colName).append(" = ? "); paras.add(e.getValue()); } } sql.append(" where "); for (int i=0; i<pKeys.length; i++) { if (i > 0) { sql.append(" and "); } sql.append(pKeys[i]).append(" = ?"); paras.add(attrs.get(pKeys[i])); } }
public void forDbSave(String tableName, String[] pKeys, Record record, StringBuilder sql, List<Object> paras) { tableName = tableName.trim(); trimPrimaryKeys(pKeys); sql.append("insert into "); sql.append(tableName).append('('); StringBuilder temp = new StringBuilder(); temp.append(") values("); int count = 0; for (Entry<String, Object> e: record.getColumns().entrySet()) { String colName = e.getKey(); if (count++ > 0) { sql.append(", "); temp.append(", "); } sql.append(colName); Object value = e.getValue(); if (value instanceof String && isPrimaryKey(colName, pKeys) && ((String)value).endsWith(".nextval")) { temp.append(value); } else { temp.append('?'); paras.add(value); } } sql.append(temp.toString()).append(')'); }
public void forModelSave(Table table, Map<String, Object> attrs, StringBuilder sql, List<Object> paras) { sql.append("insert into ").append(table.getName()).append('('); StringBuilder temp = new StringBuilder(") values("); String[] pKeys = table.getPrimaryKey(); int count = 0; for (Entry<String, Object> e: attrs.entrySet()) { String colName = e.getKey(); if (table.hasColumnLabel(colName)) { if (count++ > 0) { sql.append(", "); temp.append(", "); } sql.append(colName); Object value = e.getValue(); if (value instanceof String && isPrimaryKey(colName, pKeys) && ((String)value).endsWith(".nextval")) { temp.append(value); } else { temp.append('?'); paras.add(value); } } } sql.append(temp.toString()).append(')'); }
public void forDbUpdate(String tableName, String[] pKeys, Object[] ids, Record record, StringBuilder sql, List<Object> paras) { tableName = tableName.trim(); trimPrimaryKeys(pKeys); sql.append("update ").append(tableName).append(" set "); for (Entry<String, Object> e: record.getColumns().entrySet()) { String colName = e.getKey(); if (!isPrimaryKey(colName, pKeys)) { if (paras.size() > 0) { sql.append(", "); } sql.append(colName).append(" = ? "); paras.add(e.getValue()); } } sql.append(" where "); for (int i=0; i<pKeys.length; i++) { if (i > 0) { sql.append(" and "); } sql.append(pKeys[i]).append(" = ?"); paras.add(ids[i]); } }
public void forDbUpdate(String tableName, String[] pKeys, Object[] ids, Record record, StringBuilder sql, List<Object> paras) { tableName = tableName.trim(); trimPrimaryKeys(pKeys); sql.append("update ").append(tableName).append(" set "); for (Entry<String, Object> e: record.getColumns().entrySet()) { String colName = e.getKey(); if (!isPrimaryKey(colName, pKeys)) { if (paras.size() > 0) { sql.append(", "); } sql.append(colName).append(" = ? "); paras.add(e.getValue()); } } sql.append(" where "); for (int i=0; i<pKeys.length; i++) { if (i > 0) sql.append(" and "); sql.append(pKeys[i]).append(" = ?"); paras.add(ids[i]); } }
public void forModelUpdate(Table table, Map<String, Object> attrs, Set<String> modifyFlag, StringBuilder sql, List<Object> paras) { sql.append("update ").append(table.getName()).append(" set "); String[] pKeys = table.getPrimaryKey(); for (Entry<String, Object> e : attrs.entrySet()) { String colName = e.getKey(); if (modifyFlag.contains(colName) && !isPrimaryKey(colName, pKeys) && table.hasColumnLabel(colName)) { if (paras.size() > 0) { sql.append(", "); } sql.append(colName).append(" = ? "); paras.add(e.getValue()); } } sql.append(" where "); for (int i=0; i<pKeys.length; i++) { if (i > 0) { sql.append(" and "); } sql.append(pKeys[i]).append(" = ?"); paras.add(attrs.get(pKeys[i])); } }
public void forDbSave(String tableName, String[] pKeys, Record record, StringBuilder sql, List<Object> paras) { tableName = tableName.trim(); trimPrimaryKeys(pKeys); sql.append("insert into "); sql.append(tableName).append('('); StringBuilder temp = new StringBuilder(); temp.append(") values("); int count = 0; for (Entry<String, Object> e: record.getColumns().entrySet()) { String colName = e.getKey(); if (count++ > 0) { sql.append(", "); temp.append(", "); } sql.append(colName); Object value = e.getValue(); if (value instanceof String && isPrimaryKey(colName, pKeys) && ((String)value).endsWith(".nextval")) { temp.append(value); } else { temp.append('?'); paras.add(value); } } sql.append(temp.toString()).append(')'); }
public void forDbSave(StringBuilder sql, List<Object> paras, String tableName, String[] pKeys, Record record) { tableName = tableName.trim(); trimPrimaryKeys(pKeys); sql.append("insert into "); sql.append(tableName).append("("); StringBuilder temp = new StringBuilder(); temp.append(") values("); int count = 0; for (Entry<String, Object> e: record.getColumns().entrySet()) { String colName = e.getKey(); if (count++ > 0) { sql.append(", "); temp.append(", "); } sql.append(colName); Object value = e.getValue(); if (value instanceof String && isPrimaryKey(colName, pKeys) && ((String)value).endsWith(".nextval")) { temp.append(value); } else { temp.append("?"); paras.add(value); } } sql.append(temp.toString()).append(")"); }
public void forModelSave(Table table, Map<String, Object> attrs, StringBuilder sql, List<Object> paras) { sql.append("insert into ").append(table.getName()).append('('); StringBuilder temp = new StringBuilder(") values("); String[] pKeys = table.getPrimaryKey(); int count = 0; for (Entry<String, Object> e: attrs.entrySet()) { String colName = e.getKey(); if (table.hasColumnLabel(colName)) { if (count++ > 0) { sql.append(", "); temp.append(", "); } sql.append(colName); Object value = e.getValue(); if (value instanceof String && isPrimaryKey(colName, pKeys) && ((String)value).endsWith(".nextval")) { temp.append(value); } else { temp.append('?'); paras.add(value); } } } sql.append(temp.toString()).append(')'); }
public void forModelSave(Table table, Map<String, Object> attrs, StringBuilder sql, List<Object> paras) { sql.append("insert into ").append(table.getName()).append("("); StringBuilder temp = new StringBuilder(") values("); String[] pKeys = table.getPrimaryKey(); int count = 0; for (Entry<String, Object> e : attrs.entrySet()) { String colName = e.getKey(); if (table.hasColumnLabel(colName)) { if (count++ > 0) { sql.append(", "); temp.append(", "); } sql.append(colName); Object value = e.getValue(); if (value instanceof String && isPrimaryKey(colName, pKeys) && ((String) value).endsWith(".nextval")) { temp.append(value); } else { temp.append("?"); paras.add(value); } } } sql.append(temp.toString()).append(")"); }