com.ninja_squad.dbsetup.operation
Class DeleteAll

java.lang.Object
  extended by com.ninja_squad.dbsetup.operation.DeleteAll
All Implemented Interfaces:
Operation

@Immutable
public final class DeleteAll
extends java.lang.Object
implements Operation

An operation which deletes everything from a given database table.


Constructor Summary
protected DeleteAll(java.lang.String table)
           
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 void execute(java.sql.Connection connection, BinderConfiguration configuration)
          Executes the operation
static Operation from(java.util.List<java.lang.String> tables)
          Returns a composite operation which deletes all the rows from the given tables, in the same order as the tables.
static Operation from(java.lang.String... tables)
          Returns a composite operation which deletes all the rows from the given tables, in the same order as the tables.
static DeleteAll from(java.lang.String table)
          Returns an operation which deletes all the rows from the given table.
 int hashCode()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DeleteAll

protected DeleteAll(java.lang.String table)
Method Detail

execute

public void execute(java.sql.Connection connection,
                    BinderConfiguration configuration)
             throws java.sql.SQLException
Description copied from interface: Operation
Executes the operation

Specified by:
execute in interface Operation
Parameters:
connection - the connection used to execute the operation
configuration - the binder configuration, used to get appropriate binders based on the metadata of the prepared statements
Throws:
java.sql.SQLException - if the execution throws a SQLException

from

public static DeleteAll from(@Nonnull
                             java.lang.String table)
Returns an operation which deletes all the rows from the given table.

Parameters:
table - the table to delete everything from.

from

public static Operation from(@Nonnull
                             java.lang.String... tables)
Returns a composite operation which deletes all the rows from the given tables, in the same order as the tables. If A has a foreign key to B, which has a foreign key to C, tables should be listed in the following order: A, B, C. Otherwise, referential constraint will break. If there is a cycle in the dependencies, you might want to use a sequence of SqlOperation to disable the foreign key constraints, then delete everything from the tables, then use another sequence of SqlOperation to re-enable the foreign key constraints.

Parameters:
tables - the tables to delete everything from.

from

public static Operation from(@Nonnull
                             java.util.List<java.lang.String> tables)
Returns a composite operation which deletes all the rows from the given tables, in the same order as the tables. If A has a foreign key to B, which has a foreign key to C, tables should be listed in the following order: A, B, C. Otherwise, referential constraint will break. If there is a cycle in the dependencies, you might want to use a sequence of SqlOperation to disable the foreign key constraints, then delete everything from the tables, then use another sequence of SqlOperation to re-enable the foreign key constraints.

Parameters:
tables - the tables to delete everything from.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object