Delete subprocess instances fails if super process token is not in process state
--------------------------------------------------------------------------------
Key: JBPM-990
URL:
http://jira.jboss.com/jira/browse/JBPM-990
Project: JBoss jBPM
Issue Type: Bug
Components: Core Engine
Affects Versions: jBPM jPDL 3.2
Reporter: Olga Ivanova
Assigned To: Tom Baeyens
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);
}
---------------------------------------------------------------------------------------------------------------------------
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira