-
Type:
Bug Report
-
Resolution: Fixed
-
Priority:
L3 - Default
-
Affects Version/s: 7.14.0
-
Component/s: None
Given a query like this:
List<HistoricTaskInstance> tasks = execution .getProcessEngineServices() .getHistoryService() .createHistoricTaskInstanceQuery() .tenantIdIn("Test_Tenant") .or() .taskHadCandidateGroup("GROUP_TEST") .taskHadCandidateUser("USER_TEST") .endOr() .orderByHistoricTaskInstanceEndTime() .desc() .list();
the resulting SQL is
SELECT DISTINCT RES.*
FROM act_hi_taskinst RES
WHERE ( 1 = 1
AND RES.tenant_id_ IN ( ? ) )
AND ( 1 = 1
AND RES.id_ IN (SELECT task_id_
FROM act_hi_identitylink HIL
WHERE HIL.type_ = 'candidate'
AND HIL.user_id_ = ?
AND HIL.type_ = 'candidate'
AND HIL.group_id_ = ?) )
AND ( RES.tenant_id_ IS NULL )
ORDER BY RES.end_time_ DESC
LIMIT ? offset ?
Note that the query criteria inside the or query are concatenated with AND instead of OR.
Root Cause:
The AND is hardcoded into the SQL statement: https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/HistoricTaskInstance.xml#L321-L330
It should use the dynamic queryType like here: https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/Task.xml#L351
This is confirmed with 7.14.0 but should also affect older versions since the relevant code was introduced with CAM-4911 (7.5) and probably missed when introducing the or query support with CAM-9676 (7.12).