public class DefaultDBCleaner extends BaseDatabaseAccessor implements DBCleaner
DBCleaner. This implementation will delete all data from a database, except for the tables
that are configured as tables to preserve. This includes the tables that are listed in the property
PROPKEY_PRESERVE_TABLES, PROPKEY_PRESERVE_DATA_TABLES. and the table that is configured as
version table using the property PROPKEY_VERSION_TABLE_NAME.| Modifier and Type | Field and Description |
|---|---|
static String |
PROPKEY_PRESERVE_DATA_SCHEMAS
Property key for schemas in which none of the tables should be cleaned
|
static String |
PROPKEY_PRESERVE_DATA_TABLES
Property key for the tables that should not be cleaned
|
static String |
PROPKEY_PRESERVE_TABLES
Property that specifies which tables should not be dropped (should also not be cleaned)
|
static String |
PROPKEY_VERSION_TABLE_NAME
The key of the property that specifies the name of the datase table in which the
DB version is stored.
|
protected Set<String> |
schemasToPreserve
Names of schemas that should left untouched.
|
protected Set<String> |
tablesToPreserve
The tables that should not be cleaned
|
configuration, dbSupports, defaultDbSupport, dialect, sqlHandler| Constructor and Description |
|---|
DefaultDBCleaner() |
| Modifier and Type | Method and Description |
|---|---|
void |
cleanSchemas()
Deletes all data from the database, except for the tables that have been
configured as tablesToPreserve , and the table in which the database version is stored
|
protected void |
cleanTable(String tableName,
DbSupport dbSupport)
Deletes the data in the table with the given name.
|
protected void |
doInit(Properties configuration)
Configures this object.
|
protected Set<String> |
getItemsToPreserve(String propertyName,
boolean prefixDefaultSchema)
Gets the list of items to preserve.
|
protected boolean |
isItemToPreserve(String item,
Set<String> itemsToPreserve)
Checks whether the given item is one of the items to preserve.
|
getDbSupport, initclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitinitpublic static final String PROPKEY_PRESERVE_DATA_SCHEMAS
public static final String PROPKEY_PRESERVE_DATA_TABLES
public static final String PROPKEY_PRESERVE_TABLES
public static final String PROPKEY_VERSION_TABLE_NAME
protected Set<String> schemasToPreserve
protected void doInit(Properties configuration)
doInit in class BaseDatabaseAccessorconfiguration - The configuration, not nullpublic void cleanSchemas()
cleanSchemas in interface DBCleanerprotected void cleanTable(String tableName, DbSupport dbSupport)
tableName - The name of the table that need to be cleared, not nulldbSupport - The database support, not nullprotected boolean isItemToPreserve(String item, Set<String> itemsToPreserve)
item - The item, not nullitemsToPreserve - The items to preserve, not nullprotected Set<String> getItemsToPreserve(String propertyName, boolean prefixDefaultSchema)
propertyName - The name of the property that defines the items, not nullprefixDefaultSchema - True to prefix item with default schema when neededCopyright © 2016. All Rights Reserved.