Пример #1
0
  public static String getUpdateSQL(Model entity) {
    Map<String, String> keyValueMap = entity.toKeyValueMap();
    String updatequery = "UPDATE " + entity.tableName() + " SET ";
    for (Map.Entry<String, String> entry : keyValueMap.entrySet()) {
      updatequery += entry.getKey() + "=" + entry.getValue() + ", ";
    }

    return updatequery.substring(0, updatequery.length() - 2) + " WHERE _id = " + entity.getId();
  }
Пример #2
0
  public static String getDeleteSQL(Model entity) {

    return "DELETE FROM "
        + entity.tableName()
        + " WHERE "
        + entity.idColumnName()
        + " = "
        + entity.getId();
  }