Query all process instances, that are no sub process instances


I want to request all process instances with a certain business key, that are NOT called by any other process instances.
I tried using the following code:


But this works like I wouldn’t have added the ‘.superProcessInstanceId(null)’; meaning it just give me all process instances with the given business key (also the sub process instances).

Is there a way to achieve this, or do I have to get all and the filter the once I need?

Hi @capacia,

you are right that the superProcessInstanceId criterion with a null value has no effect on the query.
I think camunda BPM provides no filter criterion for this use case at the moment. You could use a native query instead.

It would look like this:

  .sql("SELECT * FROM ...").list();



Thanks @tasso94 for you reply. I will do so.