Uploaded image for project: 'jBPM'
  1. jBPM
  2. JBPM-990

Delete subprocess instances fails if super process token is not in process state

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • jBPM 3.2.2
    • jBPM 3.2.0
    • Runtime Engine
    • None

      There was fixed issue "delete sub process instances recursively" (see http://jira.jboss.com/jira/browse/JBPM-614) that has been fixed.
      Sub processes are deleted using following code:
      -------------------------------------------------------------------------------------------------------------------
      ProcessInstance subProcessInstance = token.getSubProcessInstance();
      if (subProcessInstance != null)

      { subProcessInstance.setSuperProcessToken(null); token.setSubProcessInstance(null); deleteProcessInstance(subProcessInstance); }

      -----------------------------------------------------------------------------------------------------------------------
      The problem is that token.getSubProcessInstance() returns something only while token is in process state, as soon as token leaves process state, getSubProcessInstance() returns null.

      The correct way to find sub process instances for current process is to query process instance by super process token, there is already defined named query in hibernate.queries.hbm.xml file - "GraphSession.findSubProcessInstances", so code should look following:
      ----------------------------------------------------------------------------------------------------------------------
      Query query = session
      .getNamedQuery("GraphSession.findSubProcessInstances");
      query.setLong("instanceId", token.getProcessInstance().getId());
      List<ProcessInstance> processInstances = query.list();

      if (processInstances == null || processInstances.isEmpty())
      return;

      for (ProcessInstance instance : processInstances)

      { instance.setSuperProcessToken(null); token.setSubProcessInstance(null); deleteProcessInstance(instance); }

      ---------------------------------------------------------------------------------------------------------------------------

            tom.baeyens Tom Baeyens (Inactive)
            olgaivanova_jira Olga Ivanova (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: