cancel
Showing results for 
Search instead for 
Did you mean: 

Sorting process instances by 'start time'

partizano
Champ in-the-making
Champ in-the-making
Hi,

I am right that there is no ability to sort process instances by 'start time' in Activiti-API?
If so, can I create JIRA issue for this? Or there is some reason not to implement this?
10 REPLIES 10

trademak
Star Contributor
Star Contributor
Yes you're right, and there's no specific reason that it isn't available.

Best regards,

smirzai
Champ on-the-rise
Champ on-the-rise
Hi all
Maybe it is not necessary. process instance id's are taken from sequence, so they are always ascending.
So the the result will be the same no matter sort is done based on instance id or start time.
ExecutionQuery.orderByProcessInstanceId  already provides ordering capability based on  process instance id.
So I think there is no need to add another sort method.
Is it so ?

trademak
Star Contributor
Star Contributor
Hi,

There's no start time in the ProcessInstance object.
The HistoryService and the HistoricProcessInstance provide the query functionality based on the start time.

Best regards,

smirzai
Champ on-the-rise
Champ on-the-rise
Hi
So do you also agree that it is not necessary to ProcessInstanceQuery.orderByProcessStartTime() and ProcessInstanceQuery.orderByProcessInstanceId is enough and will serve the same purpose ?
If yes, maybe this issue should be set to fixed or will not be done status.

I have posted a little bit more explanation in related jira issue (http://jira.codehaus.org/browse/ACT-1004) to more clarify it.

trademak
Star Contributor
Star Contributor
Hi,

I agree that start time should not be added to ProcessInstanceQuery but for a different reason.
There's no start time available in the database, so it's not possible to sort on start time.
Instead you can use the HistoricProcessInstanceQuery to sort process instances based on start time.

Best regards,

smirzai
Champ on-the-rise
Champ on-the-rise
if it is a real need and what Ronald has said in related Jira issue should be considered (assumption of not ascending id generator), then there is a possibility to join the act_ru_execution.proc_inst_id to act_hi_procinst.proc_int_id and get the start time. I had a glance at code, it seems that the history record is created as soon as process instance is created with start time, so it is possible to do this.

But the question is how much is important to support non default UUID generator. I feel it does not worth the effort.

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
how important it is? See http://jira.codehaus.org/browse/ACT-789

Resurrecting this old thread: we experienced the exact deadlock described in  http://jira.codehaus.org/browse/ACT-789, and as a result we are considering using the StrongUuidGenerator - which means we won't be able to use the executionID to replace startTime in sorts.

We definitely need to be able to sort/paginate on startTime, and I am a bit concerned about using the historical APIs to get information about active processes… this seems wrong Smiley Happy

Is there any strong design reason why we can be assured that this is a sustainable approach in the long term? Will a historic entry be created for every process started, at least as soon as it reaches its first asynchronous continuation?

Thanks!
Franck

jbarrez
Star Contributor
Star Contributor
> Will a historic entry be created for every process started, at least as soon as it reaches its first asynchronous continuation?

Yes, if your history is not disabled.

I agree it's not the best solution and that a start time on the process instance would be good to have for sure.