cancel
Showing results for 
Search instead for 
Did you mean: 

ExecutionQuery does not contain unpersisted process instance

michael_amann
Champ in-the-making
Champ in-the-making
Hi,

I'm currently experiencing troubles when trying to receive a "process call hierarchy" before the process instance is persisted to the activiti database.

The following scenario is causing me headache:

Process A is started from a unit test and the first activity is a call activity that references Process B. The first activity in Process B is a service task where I want to query the process call hierarchy (implemented as Spring bean).

So all I'm doing in the service task is to call:
runtimeService.createExecutionQuery().list()
In this scenario the result list is empty, even though two process instances should appear.

As soon as I add a user task before the service task and complete it before performing the query above, the list of results consists of the expected two entries.

Does anyone have an idea how to solve this? I need a way to query all executions, nevertheless if the process instance was paused already or not. So in other words, in the result list of createExecutionQuery() I would like to see

- all running processes as found in the database
- all running processes not yet commited

How could I achieve that?

Regards
Michael
1 REPLY 1

jbarrez
Star Contributor
Star Contributor
That's indeed how Activiti works: until a wait state is encountered, nothing is persisted to the database. That is why you see the change when you create a user task.
I'm afraid that is something you'll have to live with. The only option you have is to make the call asynchronous: in that case, the state will be saved to the database, before another thread continues process execution.