org.sormula.operation
Class DeleteOperation<R>

java.lang.Object
  extended by org.sormula.operation.SqlOperation<R>
      extended by org.sormula.operation.ModifyOperation<R>
          extended by org.sormula.operation.DeleteOperation<R>
Type Parameters:
R - class type which contains members for columns of a row in a table

public class DeleteOperation<R>
extends ModifyOperation<R>

SQL delete operation for row of type R.

Since:
1.0
Author:
Jeff Miller

Constructor Summary
DeleteOperation(Table<R> table)
          Constructs standard sql delete for primary key as:
DELETE FROM table WHERE primary key clause
DeleteOperation(Table<R> table, java.lang.String whereConditionName)
          Constructs for standard sql delete statement as:
DELETE FROM table WHERE ...
 
Method Summary
 int delete(java.lang.Object... parameters)
          Deletes rows based upon parameters.
 int delete(R row)
          Deletes a row.
 int deleteAll(java.util.Collection<R> rows)
          Deletes all rows in collection.
protected  void initBaseSql()
          Sets base sql with SqlOperation.setBaseSql(String).
protected  java.util.List<CascadeOperation<R,?>> prepareCascades(java.lang.reflect.Field field)
          Creates and prepares cascade operations based upon cascade annotations for a field.
protected  void prepareColumns(R row)
          Deprecated. 
protected  void writeColumns(R row)
          Does nothing since delete statements have no columns.
 
Methods inherited from class org.sormula.operation.ModifyOperation
close, execute, getRowsAffected, isBatch, modify, modify, modifyAll, postExecute, postExecuteCascade, preExecute, preExecuteCascade, setBatch, setParameters, setRow, setRows, setRows, setRows, setRowsAffected
 
Methods inherited from class org.sormula.operation.SqlOperation
cancel, cascade, closeCascades, closeStatement, createTargetField, getBaseSql, getConnection, getCustomSql, getNextParameter, getOperationTime, getParameters, getPreparedSql, getPreparedStatement, getQueryTimeout, getSql, getTable, getTargetTable, getTimingId, getWhereConditionName, getWhereTranslator, initOperationTime, isAutoGeneratedKeys, isIncludeIdentityColumns, isReadOnly, isTimings, logTimings, prepare, prepareCascades, prepareCheck, prepareParameters, prepareWhere, setAutoGeneratedKeys, setBaseSql, setCustomSql, setIncludeIdentityColumns, setNextParameter, setQueryTimeout, setReadOnly, setTimingId, setTimings, setWhere, setWhereTranslator, writeParameter, writeParameters, writeWhere
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DeleteOperation

public DeleteOperation(Table<R> table)
                throws OperationException
Constructs standard sql delete for primary key as:
DELETE FROM table WHERE primary key clause

Parameters:
table - delete from this table
Throws:
OperationException - if error

DeleteOperation

public DeleteOperation(Table<R> table,
                       java.lang.String whereConditionName)
                throws OperationException
Constructs for standard sql delete statement as:
DELETE FROM table WHERE ...

Parameters:
table - delete from this table
whereConditionName - name of where condition to use ("primaryKey" to delete by primary key; empty string to delete all rows in table)
Throws:
OperationException - if error
Method Detail

delete

public int delete(R row)
           throws OperationException
Deletes a row. Set parameters, executes, closes. Alias for ModifyOperation.modify(Object).

Parameters:
row - row to use for parameters
Returns:
ModifyOperation.getRowsAffected()
Throws:
OperationException - if error
Since:
1.4

deleteAll

public int deleteAll(java.util.Collection<R> rows)
              throws OperationException
Deletes all rows in collection. Set parameters, executes, closes. Alias for ModifyOperation.modifyAll(Collection).

Parameters:
rows - collection of rows to use as parameters
Returns:
ModifyOperation.getRowsAffected()
Throws:
OperationException - if error
Since:
1.4

delete

public int delete(java.lang.Object... parameters)
           throws OperationException
Deletes rows based upon parameters. Set parameters, executes, closes. Alias for ModifyOperation.modify(Object...).

Parameters:
parameters - operation parameters as objects (see ModifyOperation.setParameters(Object...))
Returns:
count of rows affected
Throws:
OperationException - if error
Since:
1.4

prepareColumns

@Deprecated
protected void prepareColumns(R row)
                       throws OperationException
Deprecated. 

Description copied from class: SqlOperation
Replaced with SqlOperation.writeColumns(Object).

Overrides:
prepareColumns in class SqlOperation<R>
Throws:
OperationException

writeColumns

protected void writeColumns(R row)
                     throws OperationException
Does nothing since delete statements have no columns.

Overrides:
writeColumns in class SqlOperation<R>
Parameters:
row - get column values from this row
Throws:
OperationException - if error

initBaseSql

protected void initBaseSql()
Sets base sql with SqlOperation.setBaseSql(String).


prepareCascades

protected java.util.List<CascadeOperation<R,?>> prepareCascades(java.lang.reflect.Field field)
                                                         throws OperationException
Creates and prepares cascade operations based upon cascade annotations for a field.

Specified by:
prepareCascades in class SqlOperation<R>
Parameters:
field - annotation is for this field of row class R
Returns:
list of cascade operations; empty list for none
Throws:
OperationException - if error