Sorry, this is jBPM 3.0.1
Duh - I just saw the DataModel Wiki
somehow I missed it on the Wiki page.
I have corrected my earlier script, for SQLServer, by adding the rest of the tables from the Execution Model. Note that JBPM_MESSAGE is not part of my 3.0.1 installation, so is omitted here.
By way of apology, here is the final script for SQLServer users, note the skirting of a FK.
delete from JBPM_LOG delete from JBPM_TIMER delete from JBPM_MODULEINSTANCE delete from JBPM_TOKENVARIABLEMAP delete from JBPM_TASKINSTANCE delete from JBPM_VARIABLEINSTANCE -- Must temporarily drop FK from Token -> ProcInstance if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_TOKEN_PROCINST]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1) ALTER TABLE [dbo].[JBPM_TOKEN] DROP CONSTRAINT FK_TOKEN_PROCINST -- Clear tables delete from JBPM_PROCESSINSTANCE delete from JBPM_TOKEN -- Re-add dropped FKs ALTER TABLE [dbo].[JBPM_TOKEN] ADD CONSTRAINT [FK_TOKEN_PROCINST] FOREIGN KEY ( [PROCESSINSTANCE_] ) REFERENCES [dbo].[JBPM_PROCESSINSTANCE] ( [ID_] ) delete from JBPM_SWIMLANEINSTANCE delete from JBPM_POOLEDACTOR delete from JBPM_TASKACTORPOOL delete from JBPM_COMMENT delete from JBPM_RUNTIMEACTION delete from JBPM_BYTEBLOCK delete from JBPM_BYTEARRAY
Why alter the foreign keys? Why not just set the JBPM_TOKEN.PROCESSINSTANCE to null on the token table, delete the process instances, and then the tokens.
Also, you might want to look into the GraphSession. In 3.1.x, there is a GraphSession.deleteProcessInstance which will automatically go through and delete everything tied to that process instance, instead of you worrying about it.
cpob is right.