All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.fluentjdbc.DatabaseDeleteBuilder Maven / Gradle / Ivy

There is a newer version: 0.5.3
Show newest version
package org.fluentjdbc;

import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;

class DatabaseDeleteBuilder extends DatabaseStatement {

    private String tableName;

    private final List whereConditions = new ArrayList<>();
    private final List whereParameters = new ArrayList<>();

    public DatabaseDeleteBuilder(String tableName) {
        this.tableName = tableName;
    }

    DatabaseDeleteBuilder setWhereFields(List whereConditions, List whereParameters) {
        this.whereConditions.addAll(whereConditions);
        this.whereParameters.addAll(whereParameters);
        return this;
    }

    public int execute(Connection connection) {
        return executeUpdate(createDeleteStatement(tableName, whereConditions), whereParameters, connection);
    }

}