JBoss.orgCommunity Documentation
It is special service for data removal from database. The article shortly describes the principles of work DBCleaner under all databases
Code that invokes methods of DBCleanService must have JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION permission;
There are several methods of DBCleanerService:
Table 50.1. API
public static void cleanWorkspaceData(WorkspaceEntry wsEntry) | Clean workspace data from database |
public static void cleanRepositoryData(RepositoryEntry repoEntry) | Cleanup repository data from database |
public static DBCleaner getWorkspaceDBCleaner(Connection jdbcConn, WorkspaceEntry wsEntry) | Returns database cleaner of workspace. |
public static DBCleaner getRepositoryDBCleaner(Connection jdbcConn, RepositoryEntry repoEntry) | Returns database cleaner of repository. Returns null in case of multi-db configuration. |
The cleaning is a part of restoring from backup and it is used in the following restore phases:
Table 50.2. Relations between restore phases and what is called on DBCleaner
clean | dbCleaner.executeCleanScripts(); |
restore | does nothing with DBCleaner |
commit | dbCleaner.executeCommitScripts(); connection.commit(); |
rollback | connection.rollback(); dbCleaner.executeRollbackScripts(); connection.commit(); |
Different approaches are used for database cleaning depending on database and JCR configuration.
Simple cleaning records from JCR table is used in case of single-db configuration.
Table 50.3. PostgreSQL, DB2 and MSSQL
executeCleanScripts() | removing all records from the database. Foreign key of JCR_SITEM table is also removed |
executeCommitScripts() | adding foreign key |
executeRollbackScripts() |
Table 50.4. Oracle, Sybase, HSQLDB, MySQL
executeCleanScripts() | removing all records from the database. Foreign key of JCR_SITEM table is also removed |
executeCommitScripts() | adding foreign key |
executeRollbackScripts() | adding foreign key |
Either removing or renaming JCR tables are used in case of mult-db configuration.
Table 50.5. PostgreSQL, DB2 and MSSQL
executeCleanScripts() | removing tables JCR_MVALUE, JCR_MREF, JCR_MITEM, initializing new tables without foreign key of JCR_MITEM table, adding root |
executeCommitScripts() | adding foreign key |
executeRollbackScripts() |
Table 50.6. Oracle, Sybase, HSQLDB, MySQL
executeCleanScripts() | renaming current tables, initializing new tables without foreign key of JCR_MITEM table, adding root node, removing indexes for some databases |
executeCommitScripts() | renaming tables, adding indexes |
executeRollbackScripts() | removing previously renamed tables, adding indexes, adding foreign key |