com.ninja_squad.dbsetup.operation
Class SqlOperation

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

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

An operation which simply executes a SQL statement (using Statement.executeUpdate(String)). It can be useful, for example, to disable or re-enable constraints before/after deleting everything from tables, or inserting into tables having cross references.


Method Summary
 boolean equals(java.lang.Object o)
           
 void execute(java.sql.Connection connection, BinderConfiguration configuration)
          Executes the operation
 int hashCode()
           
static Operation of(java.util.List<java.lang.String> sqlStatements)
          Creates a sequence of SqlOperation for the given SQL statements.
static Operation of(java.lang.String... sqlStatements)
          Creates a sequence of SqlOperation for the given SQL statements.
static SqlOperation of(java.lang.String sqlStatement)
          Creates a SqlOperation for the given SQL statement
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

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

of

public static SqlOperation of(@Nonnull
                              java.lang.String sqlStatement)
Creates a SqlOperation for the given SQL statement

Parameters:
sqlStatement - the SQL statement to execute
Returns:
the created SqlOperation

of

public static Operation of(@Nonnull
                           java.lang.String... sqlStatements)
Creates a sequence of SqlOperation for the given SQL statements.

Parameters:
sqlStatements - the SQL statements to execute
Returns:
the created sequence of operations

of

public static Operation of(@Nonnull
                           java.util.List<java.lang.String> sqlStatements)
Creates a sequence of SqlOperation for the given SQL statements.

Parameters:
sqlStatements - the SQL statements to execute
Returns:
the created sequence of operations

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 o)
Overrides:
equals in class java.lang.Object