Class DeleteBuilder


  • public class DeleteBuilder
    extends SQLBuilder
    A builder class for creating a DELETE sql statement to delete a row from a table.
    Since:
    1.4.0
    • Constructor Summary

      Constructors 
      Constructor Description
      DeleteBuilder()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      TypedStatement build​(Database db)
      Runs buildPreparedStatement and passes this object to a new instance of TypedStatement.
      int buildAndDelete​(Database db)
      Runs buildPreparedStatement, executes the statement and returns the number of rows updated.
      long buildAndLargeDelete​(Database db)
      Runs buildPreparedStatement, executes the statement and returns the the number of rows updated.
      DeleteBuilder DELETE_FROM​(java.lang.String tableName)
      Begins the DELETE statement.
      DeleteBuilder WHERE​(java.lang.String columnName, java.lang.String value)
      Specifies a condition to constrain the SELECT statement and if this is not the first WHERE added it is separated by AND.
      DeleteBuilder WHERE_BETWEEN​(java.lang.String columnName, java.lang.String start, java.lang.String stop)
      Specifies a condition to constrain the SELECT statement that checks if the specified column value equals the start or stop values or falls between those values and if this is not the first WHERE added it is separated by AND.
      DeleteBuilder WHERE_BETWEEN_OR​(java.lang.String columnName, java.lang.String start, java.lang.String stop)
      Specifies a condition to constrain the SELECT statement that checks if the specified column value equals the start or stop values or falls between those values and if this is not the first WHERE added it is separated by OR.
      DeleteBuilder WHERE_EXISTS​(QueryBuilder builder)
      Specifies a condition to constrain the SELECT statement that checks if any record exists in the sub query and if this is not the first WHERE added it is separated by AND.
      DeleteBuilder WHERE_EXISTS_OR​(QueryBuilder builder)
      Specifies a condition to constrain the SELECT statement that checks if any record exists in the sub query and if this is not the first WHERE added it is separated by OR.
      DeleteBuilder WHERE_IN​(java.lang.String columnName, java.lang.String... values)
      Specifies a condition to constrain the SELECT statement that checks if the column matches one of the specified values.
      DeleteBuilder WHERE_IN_OR​(java.lang.String columnName, java.lang.String... values)
      Specifies a condition to constrain the SELECT statement that checks if the column matches one of the specified values.
      DeleteBuilder WHERE_IS_NOT_NULL​(java.lang.String columnName)
      Specifies a condition to constrain the SELECT statement that checks if the specified column is NOT NULL and if this is not the first WHERE added it is separated by AND.
      DeleteBuilder WHERE_IS_NOT_NULL_OR​(java.lang.String columnName)
      Specifies a condition to constrain the SELECT statement that checks if the specified column is NOT NULL and if this is not the first WHERE added it is separated by OR.
      DeleteBuilder WHERE_IS_NULL​(java.lang.String columnName)
      Specifies a condition to constrain the SELECT statement that checks if the specified column is NULL and if this is not the first WHERE added it is separated by AND.
      DeleteBuilder WHERE_IS_NULL_OR​(java.lang.String columnName)
      Specifies a condition to constrain the SELECT statement that checks if the specified column is NULL and if this is not the first WHERE added it is separated by OR.
      DeleteBuilder WHERE_NOT​(java.lang.String columnName, java.lang.String value)
      Specifies an inverse condition using NOT to constrain the SELECT statement and if this is not the first WHERE added it is separated by AND.
      DeleteBuilder WHERE_NOT_BETWEEN​(java.lang.String columnName, java.lang.String start, java.lang.String stop)
      Specifies a condition to constrain the SELECT statement that checks if the specified column value does not equal the start or stop values and does not fall between those values and if this is not the first WHERE added it is separated by AND.
      DeleteBuilder WHERE_NOT_BETWEEN_OR​(java.lang.String columnName, java.lang.String start, java.lang.String stop)
      Specifies a condition to constrain the SELECT statement that checks if the specified column value does not equal the start or stop values and does not fall between those values and if this is not the first WHERE added it is separated by OR.
      DeleteBuilder WHERE_NOT_EXISTS​(QueryBuilder builder)
      Specifies a condition to constrain the SELECT statement that checks if no records exist in the sub query and if this is not the first WHERE added it is separated by AND.
      DeleteBuilder WHERE_NOT_EXISTS_OR​(QueryBuilder builder)
      Specifies a condition to constrain the SELECT statement that checks if no records exist in the sub query and if this is not the first WHERE added it is separated by OR.
      DeleteBuilder WHERE_NOT_IN​(java.lang.String columnName, java.lang.String... values)
      Specifies a condition to constrain the SELECT statement that checks if the column does not match one of the specified values.
      DeleteBuilder WHERE_NOT_IN_OR​(java.lang.String columnName, java.lang.String... values)
      Specifies a condition to constrain the SELECT statement that checks if the column does not match one of the specified values.
      DeleteBuilder WHERE_NOT_OR​(java.lang.String columnName, java.lang.String value)
      Specifies an inverse condition using NOT to constrain the SELECT statement and if this is not the first WHERE added it is separated by OR.
      DeleteBuilder WHERE_OR​(java.lang.String columnName, java.lang.String value)
      Specifies a condition to constrain the SELECT statement and if this is not the first WHERE added it is separated by OR.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • DeleteBuilder

        public DeleteBuilder()
    • Method Detail

      • DELETE_FROM

        public DeleteBuilder DELETE_FROM​(java.lang.String tableName)
        Begins the DELETE statement.
        Parameters:
        tableName - the name of the table
        Returns:
        the instance of the builder to continue building
        Throws:
        java.lang.IllegalStateException - if this is not the first method called
      • WHERE

        public DeleteBuilder WHERE​(java.lang.String columnName,
                                   java.lang.String value)
        Specifies a condition to constrain the SELECT statement and if this is not the first WHERE added it is separated by AND.
        Parameters:
        columnName - the column name to check against
        value - the expected value
        Returns:
        the instance of the builder to continue building
      • WHERE_OR

        public DeleteBuilder WHERE_OR​(java.lang.String columnName,
                                      java.lang.String value)
        Specifies a condition to constrain the SELECT statement and if this is not the first WHERE added it is separated by OR.
        Parameters:
        columnName - the column name to check against
        value - the expected value
        Returns:
        the instance of the builder to continue building
      • WHERE_NOT

        public DeleteBuilder WHERE_NOT​(java.lang.String columnName,
                                       java.lang.String value)
        Specifies an inverse condition using NOT to constrain the SELECT statement and if this is not the first WHERE added it is separated by AND.
        Parameters:
        columnName - the column name to check against
        value - the expected value
        Returns:
        the instance of the builder to continue building
      • WHERE_NOT_OR

        public DeleteBuilder WHERE_NOT_OR​(java.lang.String columnName,
                                          java.lang.String value)
        Specifies an inverse condition using NOT to constrain the SELECT statement and if this is not the first WHERE added it is separated by OR.
        Parameters:
        columnName - the column name to check against
        value - the expected value
        Returns:
        the instance of the builder to continue building
      • WHERE_IS_NULL

        public DeleteBuilder WHERE_IS_NULL​(java.lang.String columnName)
        Specifies a condition to constrain the SELECT statement that checks if the specified column is NULL and if this is not the first WHERE added it is separated by AND.
        Parameters:
        columnName - the column name to check against
        Returns:
        the instance of the builder to continue building
      • WHERE_IS_NOT_NULL

        public DeleteBuilder WHERE_IS_NOT_NULL​(java.lang.String columnName)
        Specifies a condition to constrain the SELECT statement that checks if the specified column is NOT NULL and if this is not the first WHERE added it is separated by AND.
        Parameters:
        columnName - the column name to check against
        Returns:
        the instance of the builder to continue building
      • WHERE_IS_NULL_OR

        public DeleteBuilder WHERE_IS_NULL_OR​(java.lang.String columnName)
        Specifies a condition to constrain the SELECT statement that checks if the specified column is NULL and if this is not the first WHERE added it is separated by OR.
        Parameters:
        columnName - the column name to check against
        Returns:
        the instance of the builder to continue building
      • WHERE_IS_NOT_NULL_OR

        public DeleteBuilder WHERE_IS_NOT_NULL_OR​(java.lang.String columnName)
        Specifies a condition to constrain the SELECT statement that checks if the specified column is NOT NULL and if this is not the first WHERE added it is separated by OR.
        Parameters:
        columnName - the column name to check against
        Returns:
        the instance of the builder to continue building
      • WHERE_IN

        public DeleteBuilder WHERE_IN​(java.lang.String columnName,
                                      java.lang.String... values)
        Specifies a condition to constrain the SELECT statement that checks if the column matches one of the specified values. and if this is not the first WHERE added it is separated by AND.
        Parameters:
        columnName - the column name to check against
        values - a list of expected values
        Returns:
        the instance of the builder to continue building
      • WHERE_NOT_IN

        public DeleteBuilder WHERE_NOT_IN​(java.lang.String columnName,
                                          java.lang.String... values)
        Specifies a condition to constrain the SELECT statement that checks if the column does not match one of the specified values. and if this is not the first WHERE added it is separated by AND.
        Parameters:
        columnName - the column name to check against
        values - a list of expected values
        Returns:
        the instance of the builder to continue building
      • WHERE_IN_OR

        public DeleteBuilder WHERE_IN_OR​(java.lang.String columnName,
                                         java.lang.String... values)
        Specifies a condition to constrain the SELECT statement that checks if the column matches one of the specified values. and if this is not the first WHERE added it is separated by OR.
        Parameters:
        columnName - the column name to check against
        values - a list of expected values
        Returns:
        the instance of the builder to continue building
      • WHERE_NOT_IN_OR

        public DeleteBuilder WHERE_NOT_IN_OR​(java.lang.String columnName,
                                             java.lang.String... values)
        Specifies a condition to constrain the SELECT statement that checks if the column does not match one of the specified values. and if this is not the first WHERE added it is separated by AND.
        Parameters:
        columnName - the column name to check against
        values - a list of expected values
        Returns:
        the instance of the builder to continue building
      • WHERE_BETWEEN

        public DeleteBuilder WHERE_BETWEEN​(java.lang.String columnName,
                                           java.lang.String start,
                                           java.lang.String stop)
        Specifies a condition to constrain the SELECT statement that checks if the specified column value equals the start or stop values or falls between those values and if this is not the first WHERE added it is separated by AND.
        Parameters:
        columnName - the column name to check against
        start - the inclusive beginning value
        stop - the inclusive ending value
        Returns:
        the instance of the builder to continue building
      • WHERE_NOT_BETWEEN

        public DeleteBuilder WHERE_NOT_BETWEEN​(java.lang.String columnName,
                                               java.lang.String start,
                                               java.lang.String stop)
        Specifies a condition to constrain the SELECT statement that checks if the specified column value does not equal the start or stop values and does not fall between those values and if this is not the first WHERE added it is separated by AND.
        Parameters:
        columnName - the column name to check against
        start - the inclusive beginning value
        stop - the inclusive ending value
        Returns:
        the instance of the builder to continue building
      • WHERE_BETWEEN_OR

        public DeleteBuilder WHERE_BETWEEN_OR​(java.lang.String columnName,
                                              java.lang.String start,
                                              java.lang.String stop)
        Specifies a condition to constrain the SELECT statement that checks if the specified column value equals the start or stop values or falls between those values and if this is not the first WHERE added it is separated by OR.
        Parameters:
        columnName - the column name to check against
        start - the inclusive beginning value
        stop - the inclusive ending value
        Returns:
        the instance of the builder to continue building
      • WHERE_NOT_BETWEEN_OR

        public DeleteBuilder WHERE_NOT_BETWEEN_OR​(java.lang.String columnName,
                                                  java.lang.String start,
                                                  java.lang.String stop)
        Specifies a condition to constrain the SELECT statement that checks if the specified column value does not equal the start or stop values and does not fall between those values and if this is not the first WHERE added it is separated by OR.
        Parameters:
        columnName - the column name to check against
        start - the inclusive beginning value
        stop - the inclusive ending value
        Returns:
        the instance of the builder to continue building
      • WHERE_EXISTS

        public DeleteBuilder WHERE_EXISTS​(QueryBuilder builder)
        Specifies a condition to constrain the SELECT statement that checks if any record exists in the sub query and if this is not the first WHERE added it is separated by AND.
        Parameters:
        builder - the DeleteBuilder containing the sql statement to retrieve results from
        Returns:
        the instance of the builder to continue building
      • WHERE_EXISTS_OR

        public DeleteBuilder WHERE_EXISTS_OR​(QueryBuilder builder)
        Specifies a condition to constrain the SELECT statement that checks if any record exists in the sub query and if this is not the first WHERE added it is separated by OR.
        Parameters:
        builder - the DeleteBuilder containing the sql statement to retrieve results from
        Returns:
        the instance of the builder to continue building
      • WHERE_NOT_EXISTS

        public DeleteBuilder WHERE_NOT_EXISTS​(QueryBuilder builder)
        Specifies a condition to constrain the SELECT statement that checks if no records exist in the sub query and if this is not the first WHERE added it is separated by AND.
        Parameters:
        builder - the DeleteBuilder containing the sql statement to retrieve results from
        Returns:
        the instance of the builder to continue building
      • WHERE_NOT_EXISTS_OR

        public DeleteBuilder WHERE_NOT_EXISTS_OR​(QueryBuilder builder)
        Specifies a condition to constrain the SELECT statement that checks if no records exist in the sub query and if this is not the first WHERE added it is separated by OR.
        Parameters:
        builder - the DeleteBuilder containing the sql statement to retrieve results from
        Returns:
        the instance of the builder to continue building
      • build

        public TypedStatement build​(Database db)
                             throws java.sql.SQLException
        Runs buildPreparedStatement and passes this object to a new instance of TypedStatement.
        Specified by:
        build in class SQLBuilder
        Parameters:
        db - the database to request the PreparedStatement object from
        Returns:
        a new instance of TypedStatement
        Throws:
        java.sql.SQLException - if a database access error occurs
      • buildAndDelete

        public int buildAndDelete​(Database db)
                           throws java.sql.SQLException
        Runs buildPreparedStatement, executes the statement and returns the number of rows updated.
        Parameters:
        db - the database to request the PreparedStatement object from
        Returns:
        the result of the statement as a ResultSet
        Throws:
        java.sql.SQLException - if a database access error occurs
      • buildAndLargeDelete

        public long buildAndLargeDelete​(Database db)
                                 throws java.sql.SQLException
        Runs buildPreparedStatement, executes the statement and returns the the number of rows updated. This method should be used when the returned row count may exceed Integer.MAX_VALUE.
        Parameters:
        db - the database to request the PreparedStatement object from
        Returns:
        the result of the statement as a ResultSet
        Throws:
        java.sql.SQLException - if a database access error occurs