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

    jBPM4: Error deleting process definition history (with fix)

      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);
      


        • 1. Re: jBPM4: Error deleting process definition history (with f
          jbarrez

          Could you paste your unit test?

          • 2. Re: jBPM4: Error deleting process definition history (with f

            I'm trying to condense it into a smaller test case because of the large number of dependencies.

            The error kept popping up after a svn update because the delete of a HistoryProcessInstanceImpl was not cascaded to the set of historyActivityInstances. I changed the Hibernate configuration in jbpm.history.hbm.xml for that part to this:

            <set name="historyActivityInstances" cascade="all" inverse="true">
             <key foreign-key="FK_HACTI_HPROCI" on-delete="cascade">
             <column name="HPROCI_" index="IDX_HACTI_HPROCI"/>
             </key>
             <one-to-many class="HistoryActivityInstanceImpl" />
            </set>