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

Fails to start a process with CorrelationKey which is unique but includes correlation properties of an existing correlation key

    Details

      Description

      After you start a process with a multi-valued CorrelationKey ("ABC", "DEF", "DEF"), next starting a process with a multi-valued CorrelationKey ("ABC", "DEF", "GHI") fails with Exception saying that the CorrelationKey already exists:

      java.lang.RuntimeException: CorrelationKey [name=null, properties=[CorrelationPropertyInfo [name=null, value=ABC], CorrelationPropertyInfo [name=null, value=DEF], CorrelationPropertyInfo [name=null, value=GHI]]] already exists
      	at org.jbpm.persistence.JpaProcessPersistenceContext.persist(JpaProcessPersistenceContext.java:119)
      	at org.jbpm.persistence.processinstance.JPAProcessInstanceManager.addProcessInstance(JPAProcessInstanceManager.java:90)
      	at org.jbpm.process.instance.AbstractProcessInstanceFactory.createProcessInstance(AbstractProcessInstanceFactory.java:47)
      	at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:258)
      	at org.jbpm.process.instance.ProcessRuntimeImpl.createProcessInstance(ProcessRuntimeImpl.java:240)
      	at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:223)
      	at org.drools.core.impl.StatefulKnowledgeSessionImpl.startProcess(StatefulKnowledgeSessionImpl.java:1884)
      

      The problem is SQL of the named query "GetProcessInstanceIdByCorrelation".

      MySQL example)

      select correlatio0_.processInstanceId as col_0_0_ from CorrelationKeyInfo correlatio0_ left outer join CorrelationPropertyInfo properties1_ on correlatio0_.keyId=properties1_.correlationKey_keyId where cast(3 as signed)=(select count(correlatio2_.propertyId) from CorrelationPropertyInfo correlatio2_ where correlatio2_.correlationKey_keyId=correlatio0_.keyId) and (properties1_.value in ('ABC' , 'DEF' , 'GHI')) group by correlatio0_.keyId , correlatio0_.processInstanceId having count(correlatio0_.keyId)=3;
      

      This SQL matches the following data.

      CorrelationKeyInfo
      +-------+------+-------------------+---------+
      | keyId | name | processInstanceId | OPTLOCK |
      +-------+------+-------------------+---------+
      |     1 | NULL |                 1 |       0 |
      +-------+------+-------------------+---------+
      
      CorrelationPropertyInfo
      +------------+------+-------+---------+----------------------+
      | propertyId | name | value | OPTLOCK | correlationKey_keyId |
      +------------+------+-------+---------+----------------------+
      |          1 | NULL | ABC   |       0 |                    1 |
      |          2 | NULL | DEF   |       0 |                    1 |
      |          3 | NULL | DEF   |       0 |                    1 |
      +------------+------+-------+---------+----------------------+
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                swiderski.maciej Maciej Swiderski
                Reporter:
                tkobayashi Toshiya Kobayashi
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: