Retrieve identity links and tasks in a single database call?

We are experiencing a similar issue to the following forum post except our issue is related to identity links.

http://forum.flowable.org/t/transaction-management-and-propagation-modes-in-flowable/310

In our case, we are seeing a NPE in the GetIdentityLinksForTaskCmd due to the task not being found as a result of the it being completed by another thread between the call to retrieve the tasks and the call to retrieve the identity links for each task. The identity links in our case are retrieved to build the HATEOS links for our REST response.

Has any consideration been given to the idea of retrieving tasks with their identity links in single call to the database via the TaskQuery class similar to what is done for variables?

Code Snippet:
TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(processId);
List taskList = taskQuery.list();

// Retrieve identity links since they are needed to build HATEOS links.
for (Task t : taskList) {
List identityLinks = managementService.executeCommand(new GetIdentityLinksForTaskCmd(taskId));
}

Hi Rob,

I think it makes a lot of sense to add identity links to the task query (similar to variables).
No good reason why this hasn’t been done yet.

Best regards,

Tijs

Hi Tijs,

I created the following pull request to add this functionality.

https://github.com/flowable/flowable-engine/pull/294

thanks,
Rob