Skip to content

Commit e8dda66

Browse files
committed
Fix querying (historic) plan item instances with local variables on SQL Server, DB2 and Oracle
1 parent aa7d3ee commit e8dda66

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

modules/flowable-cmmn-engine/src/main/resources/org/flowable/cmmn/db/mapping/entity/HistoricPlanItemInstance.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@
344344
</select>
345345

346346
<select id="selectHistoricPlanItemInstancesWithLocalVariablesByQueryCriteria" parameterType="org.flowable.cmmn.engine.impl.history.HistoricPlanItemInstanceQueryImpl" resultMap="historicPlanItemInstanceResultMapWithVariables">
347-
<if test="needsPaging">${limitBefore}</if>
348347
SELECT RES.*
349348
<if test="includeLocalVariables">,
350349
VAR.ID_ as VAR_ID_, VAR.NAME_ as VAR_NAME_, VAR.VAR_TYPE_ as VAR_TYPE_, VAR.REV_ as VAR_REV_,
@@ -355,13 +354,15 @@
355354
VAR.TEXT_ as VAR_TEXT_, VAR.TEXT2_ as VAR_TEXT2_, VAR.LONG_ as VAR_LONG_
356355
</if>
357356
FROM (
357+
<!-- top 100 percent is only needed when doing order by in a subselect -->
358358
<if test="needsPaging">${limitBefore}</if>
359-
SELECT RES.* <if test="needsPaging">${limitBetween}</if>
359+
SELECT <if test="_databaseId == 'mssql'">top 100 percent</if> RES.* <if test="needsPaging">${limitBetween}</if>
360360
<include refid="selectHistoricPlanItemInstancesByQueryCriteriaSql"/>
361361
${orderBy}
362362
<if test="needsPaging">${limitAfter}</if>
363363
) RES
364364
left outer join ${prefix}ACT_HI_VARINST VAR ON RES.ID_ = VAR.SUB_SCOPE_ID_ and VAR.SCOPE_TYPE_= 'cmmn'
365+
${outerJoinOrderBy}
365366
</select>
366367

367368
<select id="selectHistoricPlanItemInstancesCountByQueryCriteria" parameterType="org.flowable.cmmn.engine.impl.history.HistoricPlanItemInstanceQueryImpl" resultType="long">

modules/flowable-cmmn-engine/src/main/resources/org/flowable/cmmn/db/mapping/entity/PlanItemInstance.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@
364364
</select>
365365

366366
<select id="selectPlanItemInstancesWithLocalVariablesByQueryCriteria" parameterType="org.flowable.cmmn.engine.impl.runtime.PlanItemInstanceQueryImpl" resultMap="planItemInstanceResultMapWithVariables">
367-
<if test="needsPaging">${limitBefore}</if>
368367
SELECT RES.*
369368
<if test="includeLocalVariables">,
370369
VAR.ID_ as VAR_ID_, VAR.NAME_ as VAR_NAME_, VAR.TYPE_ as VAR_TYPE_, VAR.REV_ as VAR_REV_,
@@ -375,13 +374,15 @@
375374
VAR.TEXT_ as VAR_TEXT_, VAR.TEXT2_ as VAR_TEXT2_, VAR.LONG_ as VAR_LONG_
376375
</if>
377376
FROM (
377+
<!-- top 100 percent is only needed when doing order by in a subselect -->
378378
<if test="needsPaging">${limitBefore}</if>
379-
SELECT RES.* <if test="needsPaging">${limitBetween}</if>
379+
SELECT <if test="_databaseId == 'mssql'">top 100 percent</if> RES.* <if test="needsPaging">${limitBetween}</if>
380380
<include refid="selectPlanItemInstancesByQueryCriteriaSql"/>
381381
${orderBy}
382382
<if test="needsPaging">${limitAfter}</if>
383383
) RES
384384
left outer join ${prefix}ACT_RU_VARIABLE VAR ON RES.ID_ = VAR.SUB_SCOPE_ID_ and VAR.SCOPE_TYPE_= 'cmmn'
385+
${outerJoinOrderBy}
385386
</select>
386387

387388
<select id="selectPlanItemInstanceCountByQueryCriteria" parameterType="org.flowable.cmmn.engine.impl.runtime.PlanItemInstanceQueryImpl" resultType="long">

0 commit comments

Comments
 (0)