Pagination issue with sql for task query when variables are included

Description

While using the REST interface querying for tasks with the process instance variables included in the result pagination does not work properly. The issue is that the query does a left outer join between ACT_RU_TASK and ACT_RU_VARIABLE so there is one row for each variable in each task and the OFFSET and LIMIT are applied to that result rather than just the list of tasks.
My solution to this issue was to move the ORDER BY, OFFSET and LIMIT to a nested select call:

WHERE RES.ID_ in (SELECT RES.ID_ FROM ${prefix}ACT_RU_TASK RES
<include refid="commonSelectTaskByQueryCriteriaSql"/>
${orderBy}
${limitAfter}
)

I have attached the full Task.xml file that I am using.

Environment

Ubuntu 12.04, tomcat7, java 1.6.0.27, postgres 9.1

Attachments

Assignee

Joram Barrez

Reporter

Nick Romanyshyn

Labels

None

Components

Affects versions

Priority

Major
Configure