I have a use case that requires me to query for all receive tasks for a given process instance. Intuitively, it seems I should be able to get this information in one query as follows:
// find the wait task that is awaiting a mailing response signal
Execution execution = runtimeService.createExecutionQuery()
.activityId("awaitYearlyMailingResponse")
.processInstanceBusinessKey(PROSPECT_MAILING_PROCESS_BUSINESS_KEY)
.singleResult();
////////////////////////////////////////////////////////
// This fails, as execution is unexpectedly null here //
////////////////////////////////////////////////////////
assertNotNull(execution);
// deliver receive mailing response signal
runtimeService.signal(execution.getId(),
Collections.singletonMap("askedOffMailingList", (Object) false)); // was not an ask-off-list response
Instead, the only way I found I could get the execution for this java receive task for the given process instance was with two separate queries as follows:
ProcessInstance processInstance = runtimeService
.createProcessInstanceQuery()
.processInstanceBusinessKey(PROSPECT_MAILING_PROCESS_BUSINESS_KEY)
.singleResult();
// find the wait task that is awaiting a mailing response signal
Execution execution = runtimeService.createExecutionQuery()
.activityId("awaitYearlyMailingResponse")
.processInstanceBusinessKey(processInstance.getId())
.singleResult();
//////////////////////////////////////////////////////////////////////////////////
// Returns expected result, but why should I have to do two queries? :( *pouts* //
//////////////////////////////////////////////////////////////////////////////////
assertNotNull(execution);
// deliver receive mailing response signal
runtimeService.signal(execution.getId(),
Collections.singletonMap("askedOffMailingList", (Object) false)); // was not an ask-off-list response
Is there a way to get the desired result in one query?