コード例 #1
0
  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()));
  }
コード例 #2
0
  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) + ")";
    }
  }
コード例 #3
0
 public String selectAll(TableDescription table) {
   return format("SELECT %s FROM %s", table.getSelectClause(), table.getFromClause());
 }
コード例 #4
0
 public String existsById(TableDescription table) {
   return format("SELECT 1 FROM %s WHERE %s", table.getTableName(), idPredicate(table));
 }
コード例 #5
0
 public String deleteAll(TableDescription table) {
   return format("DELETE FROM %s", table.getTableName());
 }
コード例 #6
0
 public String count(TableDescription table) {
   return format("SELECT count(*) FROM %s", table.getFromClause());
 }
コード例 #7
0
 private String idPredicate(TableDescription table) {
   return formatParameters(table.getPkColumns(), AND);
 }
コード例 #8
0
 protected Sort sortById(TableDescription table) {
   return new Sort(Direction.ASC, table.getPkColumns());
 }
コード例 #9
0
  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));
  }