Package org.dbunit.operation
Class TruncateTableOperation
java.lang.Object
org.dbunit.operation.DatabaseOperation
org.dbunit.operation.AbstractOperation
org.dbunit.operation.DeleteAllOperation
org.dbunit.operation.TruncateTableOperation
Truncate tables present in the specified dataset. If the dataset does not
contains a particular table, but that table exists in the database,
the database table is not affected. Table are truncated in
reverse sequence.
This operation has the same effect of as DeleteAllOperation.
TruncateTableOperation is faster, and it is non-logged, meaning it cannot be
rollback. DeleteAllOperation is more portable because not all database vendor
support TRUNCATE_TABLE TABLE statement.
- Since:
- Apr 10, 2003
- Version:
- $Revision$
- Author:
- Manuel Laflamme
- See Also:
-
Field Summary
Fields inherited from class org.dbunit.operation.DatabaseOperation
CLEAN_INSERT, DELETE, DELETE_ALL, INSERT, NONE, REFRESH, TRUNCATE_TABLE, UPDATE -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute(IDatabaseConnection connection, IDataSet dataSet) Executes this operation on the specified database using the specified dataset contents.protected StringReturns the SQL command prefix used to delete all rows of a table.protected StringgetDeleteAllCommandSuffix(IDatabaseConnection connection) Returns a suffix appended to the delete-all SQL statement for the given connection.Methods inherited from class org.dbunit.operation.AbstractOperation
getQualifiedNameMethods inherited from class org.dbunit.operation.DatabaseOperation
CLOSE_CONNECTION, TRANSACTION
-
Method Details
-
getDeleteAllCommand
Description copied from class:DeleteAllOperationReturns the SQL command prefix used to delete all rows of a table.- Overrides:
getDeleteAllCommandin classDeleteAllOperation- Returns:
- the SQL command prefix used to delete all rows of a table.
-
getDeleteAllCommandSuffix
Description copied from class:DeleteAllOperationReturns a suffix appended to the delete-all SQL statement for the given connection. The default implementation returns an empty string.- Overrides:
getDeleteAllCommandSuffixin classDeleteAllOperation- Parameters:
connection- the database connection the statement will be executed on.- Returns:
- the SQL statement suffix.
- Throws:
SQLException- if determining the suffix requires a database access that fails.
-
execute
public void execute(IDatabaseConnection connection, IDataSet dataSet) throws DatabaseUnitException, SQLException Description copied from class:DatabaseOperationExecutes this operation on the specified database using the specified dataset contents.- Overrides:
executein classDeleteAllOperation- Parameters:
connection- the database connection.dataSet- the dataset to be used by this operation.- Throws:
DatabaseUnitException- if a DbUnit-specific error occurs while executing the operation.SQLException- if a database access error occurs while executing the operation.
-