Identity link configuration error with custom idm

In my springboot app I have disabled idm service and I am the following query to get tasks of user or his group:

SELECT RES.* FROM ACT_RU_TASK RES LEFT JOIN ACT_RU_IDENTITYLINK IL ON RES.ID_ = IL.TASK_ID_ WHERE (RES.ASSIGNEE_ = #{username}) OR (IL.USER_ID_ = #{username}) OR (IL.GROUP_ID_ IN (#{groupIds})) AND RES.PROC_INST_ID_ IS NULL

and then I try to map Task.class to a custom TaskDto.class.
When I try to get Identity links(task.getIdentityLinks()) I am getting the following error:

ava.lang.NullPointerException: Cannot invoke "org.flowable.common.engine.impl.interceptor.CommandContext.getEngineConfigurations()" because the return value of "org.flowable.variable.service.impl.util.CommandContextUtil.getCommandContext()" is null
	at org.flowable.task.service.impl.persistence.entity.TaskEntityImpl.getTaskEngineConfiguration(TaskEntityImpl.java:812) ~[flowable-task-service-7.0.1.jar:7.0.1]
	at org.flowable.task.service.impl.persistence.entity.TaskEntityImpl.getIdentityLinkServiceConfiguration(TaskEntityImpl.java:803) ~[flowable-task-service-7.0.1.jar:7.0.1]
	at org.flowable.task.service.impl.persistence.entity.TaskEntityImpl.getIdentityLinks(TaskEntityImpl.java:291) ~[flowable-task-service-7.0.1.jar:7.0.1]

Is the error related with me disabling idm service? I would expect that this line task.getIdentityLinks() wouldn’t try to make a call to db.

How are you getting the task?

When you use the queries you need to do includeIdentityLinks() for the identity links of the task to be returned. Otherwise, they will be lazy loaded and that can fail.

Cheers,
Filip

Thanks @filiphr, yes, I tried that and it works!