TaskQuery: custom orderBy

136 views
Skip to first unread message

Torsten Geise

unread,
Oct 22, 2015, 8:27:08 AM10/22/15
to camunda BPM users
Hi,

Is it possible to perform a TaskQuery.listPage with custom "orderBy"?

We want to order the resulting tasklist by followUpDate (if present) or taskCreateTime (if followUpDate is null).

Thanks,
Torsten

Matthijs Burke

unread,
Oct 22, 2015, 10:45:18 AM10/22/15
to camunda BPM users

Torsten Geise

unread,
Oct 23, 2015, 4:31:54 PM10/23/15
to camunda BPM users
Hi Mat,

thanks for the response. I know that I can use these methods in a task query. But I want to make a custom task query and order by followUpDate OR createTime. Something like this:
if followUpDate is not null
  use followUpDate for sorting
else 
  use createTime for sorting

I could imagine writing a custom comparator and set this comparator as orderBy clause in the TaskQuery, e.g. TaskQuery.createTaskQuery().orderBy(myComparator).list.

Best regards,
Torsten

thorben....@camunda.com

unread,
Oct 26, 2015, 4:20:50 AM10/26/15
to camunda BPM users
Hi Torsten,

You could write a native task query [1]. Sorting is implemented in the SQL query, not in Java. Sorting the query results on the application-side is not practicable when result pagination is used. Combining two orderings in the way you describe could be solved in the query by generating a temporary column with the desired dates and ordering over that. However, this is not doable with API.

Cheers,
Thorben

[1] https://docs.camunda.org/manual/7.3/guides/user-guide/#process-engine-process-engine-api-native-queries
Reply all
Reply to author
Forward
0 new messages