Пример #1
0
 public void forModelSave(
     TableInfo tableInfo, Map<String, Object> attrs, StringBuilder sql, List<Object> paras) {
   sql.append("insert into \"").append(tableInfo.getTableName()).append("\"(");
   StringBuilder temp = new StringBuilder(") values(");
   for (Entry<String, Object> e : attrs.entrySet()) {
     String colName = e.getKey();
     if (tableInfo.hasColumnLabel(colName)) {
       if (paras.size() > 0) {
         sql.append(", ");
         temp.append(", ");
       }
       sql.append("\"").append(colName).append("\"");
       temp.append("?");
       paras.add(e.getValue());
     }
   }
   sql.append(temp.toString()).append(")");
 }
Пример #2
0
 public void forModelUpdate(
     TableInfo tableInfo,
     Map<String, Object> attrs,
     Set<String> modifyFlag,
     String primaryKey,
     Object id,
     StringBuilder sql,
     List<Object> paras) {
   sql.append("update \"").append(tableInfo.getTableName()).append("\" set ");
   for (Entry<String, Object> e : attrs.entrySet()) {
     String colName = e.getKey();
     if (!primaryKey.equalsIgnoreCase(colName)
         && modifyFlag.contains(colName)
         && tableInfo.hasColumnLabel(colName)) {
       if (paras.size() > 0) sql.append(", ");
       sql.append("\"").append(colName).append("\" = ? ");
       paras.add(e.getValue());
     }
   }
   sql.append(" where \"").append(primaryKey).append("\" = ?");
   paras.add(id);
 }