public String insert(TableDescription table, Map<String, Object> columns) {

    return format(
        "INSERT INTO %s (%s) VALUES (%s)",
        table.getTableName(),
        collectionToDelimitedString(columns.keySet(), COMMA),
        repeat("?", COMMA, columns.size()));
  }
  private String idsPredicate(TableDescription table, int idsCount) {
    Assert.isTrue(idsCount > 0, "idsCount must be greater than zero");

    List<String> idColumnNames = table.getPkColumns();

    if (idsCount == 1) {
      return idPredicate(table);

    } else if (idColumnNames.size() > 1) {
      return repeat("(" + formatParameters(idColumnNames, AND) + ")", OR, idsCount);

    } else {
      return idColumnNames.get(0) + " IN (" + repeat("?", COMMA, idsCount) + ")";
    }
  }
 public String selectAll(TableDescription table) {
   return format("SELECT %s FROM %s", table.getSelectClause(), table.getFromClause());
 }
 public String existsById(TableDescription table) {
   return format("SELECT 1 FROM %s WHERE %s", table.getTableName(), idPredicate(table));
 }
 public String deleteAll(TableDescription table) {
   return format("DELETE FROM %s", table.getTableName());
 }
 public String count(TableDescription table) {
   return format("SELECT count(*) FROM %s", table.getFromClause());
 }
 private String idPredicate(TableDescription table) {
   return formatParameters(table.getPkColumns(), AND);
 }
 protected Sort sortById(TableDescription table) {
   return new Sort(Direction.ASC, table.getPkColumns());
 }
  public String update(TableDescription table, Map<String, Object> columns) {

    return format(
        "UPDATE %s SET %s WHERE %s",
        table.getTableName(), formatParameters(columns.keySet(), COMMA), idPredicate(table));
  }