2 Replies Latest reply on Jul 9, 2009 10:21 AM by Kevin Wetzels

    jBPM4: Error deleting process definition history (with fix)

    Kevin Wetzels Newbie

      I'm currently running against jBPM 4 trunk and encountered following error when cleaning up after a test case:

      Caused by: java.sql.SQLException: Integrity constraint violation FK_HAI_HPI table: JBPM4_HIST_ACTINST in statement [delete from JBPM4_HIST_PROCINST where ID_=? and DBVERSION_=?]
       at org.hsqldb.jdbc.Util.throwError(Unknown Source)
       at org.hsqldb.jdbc.jdbcPreparedStatement.executeUpdate(Unknown Source)
       at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
       at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2551)
       ... 37 more
      


      Turning around the order of deletion in DeleteDeploymentCmd fixes this issue on my end. Here's the diff:

      Index: modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java
      ===================================================================
      --- modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java (revision 5252)
      +++ modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java (working copy)
      @@ -72,12 +72,15 @@
       .list();
      
       if (cascade) {
      +
      + dbSession.deleteProcessDefinitionHistory(processDefinitionId);
      +
       for (ProcessInstance processInstance: processInstances) {
       dbSession.deleteProcessInstance(processInstance.getId(), true);
       }
      
      - dbSession.deleteProcessDefinitionHistory(processDefinitionId);
      
      +
       } else {
       if (!processInstances.isEmpty()) {
       throw new JbpmException("cannot delete deployment "+deploymentId+": still executions for "+processDefinition+": "+processInstances);