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

DbSessionImpl.deleteProcessDefinitionHistory causes foreign key constrain violation for FK_HACTI_HPROCI

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • jBPM 4.x
    • jBPM 4.4
    • None

      DbSessionImpl.deleteProcessDefinitionHistory(String processDefinitionId) needs to remove HistoryActivityInstanceImpl when deleting HistoryProcessInstanceImpl since there is a foreign key constrain FK_HACTI_HPROCI in the hibernate mapping, the following implementation should do the trick:

      public void deleteProcessDefinitionHistory(String processDefinitionId) {
      List<HistoryProcessInstanceImpl> historyProcessInstances = session
      .createCriteria(HistoryProcessInstanceImpl.class)
      .add(Restrictions.eq("processDefinitionId", processDefinitionId))
      .list();

      for (HistoryProcessInstanceImpl hpi : historyProcessInstances) {

      List<HistoryActivityInstanceImpl> historyActivityInstances = session
      .createCriteria(HistoryActivityInstanceImpl.class)
      .add(Restrictions.eq("historyProcessInstance", hpi))
      .list();
      for (HistoryActivityInstanceImpl hai : historyActivityInstances)

      { session.delete(hai); }

      session.delete(hpi);
      }
      }

              Unassigned Unassigned
              mwohlf_jira Michael Wohlfart (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated: