cancel
Showing results for 
Search instead for 
Did you mean: 

selectTaskByQueryCriteria returns null

aseem
Champ in-the-making
Champ in-the-making
activiti-engine version - 5.17.0
Hi,

With the following call to taskService,


org.activiti.engine.task.Task task = taskService.createTaskQuery()
                .taskTenantId("tenantId")
                .taskId("1630666")
                .singleResult();


the resultant task is being returned as null.

org.apache.ibatis.transaction.managed.ManagedTransaction  - Opening JDBC Connection
org.activiti.engine.impl.persistence.entity.TaskEntity.selectTaskByQueryCriteria  - ooo Using Connection [Transaction-aware proxy for target Connection  from DataSource [org.apache.commons.dbcp.BasicDataSource@4cede921]]
org.activiti.engine.impl.persistence.entity.TaskEntity.selectTaskByQueryCriteria  - ==>  Preparing: select distinct RES.* from ACT_RU_TASK RES WHERE RES.ID_ = ? and RES.TENANT_ID_ = ? order by RES.ID_ asc LIMIT ? OFFSET ?
org.activiti.engine.impl.persistence.entity.TaskEntity.selectTaskByQueryCriteria  - ==> Parameters: 1630666(String), tenantId(String), 2147483647(Integer), 0(Integer)
org.activiti.engine.impl.persistence.entity.TaskEntity.selectTaskByQueryCriteria  - <==      Total: 0
org.activiti.engine.impl.db.DbSqlSession  - flush summary: 0 insert, 0 update, 0 delete.
org.activiti.engine.impl.db.DbSqlSession  - now executing flush…
org.apache.ibatis.transaction.managed.ManagedTransaction  - Closing JDBC Connection [Transaction-aware proxy for target Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@67b2ccc4]]
org.activiti.engine.impl.interceptor.LogInterceptor  - — TaskQueryImpl finished ——

If I run the same query directly on mysql db, I get the expected row in the resultset. I know this might not be enough information, but just wished to know if anyone else has seen this problem before. Is it related to some cache not being refreshed and trying to read stale data or something?
3 REPLIES 3

trademak
Star Contributor
Star Contributor
When are you executing the TaskService call? Inside the process instance execution?

Best regards,

aseem
Champ in-the-making
Champ in-the-making
Yes. I can see an entry in ACT_RU_EXECUTION for the corresponding PROC_INST_ID_ which I assume means that I'm making that call inside the process instance execution. Does that make sense?

aseem
Champ in-the-making
Champ in-the-making
Guess I found out the problem. I was deleting workflow instance which might be invalidating the cache, but since the transaction wasn't committed yet, it explains why I could see that taskId in the ACT_RU_TASK table but not in localCache.

So this was a non issue, but a problem in the client code.

Thanks