Task Query: Sort Tasks by process variable

Hi, i want to sort the tasks by the value of the process variables.

I explored solving it using native queries but i want the solution to be extensible for any type of task query.

Wanted to check the following:

(1) Is it possible to suffix the query generated by task query with where NAME_=’’ order by LONG_/TEXT_? what is your suggestion here? in that case, what is the direction, how do i create and inject a custom xml into mysql? Lets say i have 10000 records at any point of time, Will it improve my performance by sorting it at database level instead of application side sorting.
(2) Is there a way to exploit native query for this and make it generic for any task
(3) Is flowable planning to release this feature any time soon?

If you have not already you may want to take a look at the advanced, custom SQL section of the docs:

Is it possible to get the query generated by createTaskQuery() Method. I am planning to get the query generated by createTaskQuery and do a left join with task_var and do a order by on the variable value. Thanks.

You can see the output of any sql executed by the engine by setting the logging level (e.g. when using log4j):


1 Like

I want to modify the sql in the runtime so that i can suffix it with some join query.

That’s not possible, unless you overwrite the mapping xml and the MybatisTaskDataManager with a custom implementation (which is quite low-level).

Please can you suggest ways through which i can inject my custom mapping.xml and MybatisTraskDataManager to the Flowable engine.

Doing that is not that easy, you’d need to swap out many low-level things.
E.g. (didn’t test this), you’d have to override ProcessEngineConfigurationImpl#getMyBatisXmlConfigurationStream (or set the mybatisMappingFile) to read your xml config vs the default one. Assuming you would need to pass parameters to the query, you also would need to inject your own DataManager impl class into the process engine configuration (extending from the MybatisTaskManager).