JBoss.orgCommunity Documentation

Chapter 43. DBCleanerService

43.1. API
43.2. How it works
43.3. Scripts in detail
43.4. Few words in addition

There is two methods of DBCleanerService:


removeWorkspaceData takes workspaces configs from RepositoryEntry and clean each workspace using removeRepositoryData.

Lets see removeWorkspaceData in detail:

Single and Multi DB scripts examples

In case of: dbDialect = "MySQL" and isMultiDB="true", will use "conf/storage/cleanup/jcr-mjdbc.mysql.sql"

DROP TABLE JCR_MREF;
DROP TABLE JCR_MVALUE;
DROP TABLE JCR_MITEM;

In case of: dbDialect = "PgSQL" and isMultiDB="false", will use "conf/storage/cleanup/jcr-sjdbc.pgsql.sql"

delete from JCR_SVALUE where exists(select * from JCR_SITEM where JCR_SITEM.ID=JCR_SVALUE.PROPERTY_ID and JCR_SITEM.CONTAINER_NAME=?);
delete from JCR_SREF where exists(select * from JCR_SITEM where JCR_SITEM.ID=JCR_SREF.PROPERTY_ID and JCR_SITEM.CONTAINER_NAME=?);
delete from JCR_SITEM where CONTAINER_NAME=?;

But what is the strage coment is in "conf/storage/cleanup/jcr-sjdbc.sql" ?

delete from JCR_SVALUE where exists(select * from JCR_SITEM where JCR_SITEM.ID=JCR_SVALUE.PROPERTY_ID and JCR_SITEM.CONTAINER_NAME=?);
delete from JCR_SREF where exists(select * from JCR_SITEM where JCR_SITEM.ID=JCR_SREF.PROPERTY_ID and JCR_SITEM.CONTAINER_NAME=?);
delete from JCR_SITEM where I_CLASS=2 and CONTAINER_NAME=?;
/*$CLEAN_JCR_SITEM_DEFAULT*/;

/*$CLEAN_JCR_SITEM_DEFAULT*/ - some database may throw constraint violaion exception according to JCR_FK_SITEM_PARENT FOREIGN KEY in case of ordinary "" delete from JCR_SITEM where CONTAINER_NAME=? query. So there is special method, that will be executed on /*$CLEAN_JCR_SITEM_DEFAULT*/. It a bit slowly, but safe.