cancel
Showing results for 
Search instead for 
Did you mean: 

Get all tasks along with all candidate users

samantha
Champ in-the-making
Champ in-the-making
Hi,
How to retrieve all tasks along with all candidate users attached to this task?

Manage to retrieve all tasks like this:
List<Task> taskLists=taskService.createTaskQuery().orderByTaskName().asc().list();

I want to get all candidate users of each task. I will display it in a table (datatable primefaces)
Awaiting for a reply
Thanks
3 REPLIES 3

trademak
Star Contributor
Star Contributor
That's not possible using the default query API, you would need to write a custom query for it.
If you create a JIRA we can look into supporting with the default query API.

Best regards,

samantha
Champ in-the-making
Champ in-the-making
Ok I even write a custom query and yet I don't get the userId.


private static ManagementService managementService;

public static List<Task> retrieveAllTasks(){
    ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
    TaskService taskService = processEngine.getTaskService();

    String taskTable = managementService.getTableName(TaskEntity.class);
    String identityLinkTable = managementService.getTableName(IdentityLinkEntity.class);

    List<Task> tasksList = taskService.createNativeTaskQuery().sql("select _TASK.*" +
        "  from " + taskTable + " _TASK" +
        "  join " + identityLinkTable + " _LINK on _TASK.ID_ = _LINK.TASK_ID_" +
        " where _LINK.TYPE_ = 'candidate'").list();

return tasksList;


The same query when I execute it in sqldeveloper, I get all values. Why can't I get same in my list?
Glad if you can help.
Thanks

jbarrez
Star Contributor
Star Contributor
Im assuming (not checked the code) it tries to map to a Task object here? 
An alternative could be something like this: http://www.jorambarrez.be/blog/2014/01/17/execute-custom-sql-in-activiti/