/
Execution.xml
556 lines (505 loc) · 24 KB
/
Execution.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
under one or more contributor license agreements. See the NOTICE file
distributed with this work for additional information regarding copyright
ownership. Camunda licenses this file to you under the Apache License,
Version 2.0; you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity">
<!-- EXECUTION INSERT -->
<insert id="insertExecution" parameterType="org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity">
insert into ${prefix}ACT_RU_EXECUTION
(
ID_,
ROOT_PROC_INST_ID_,
PROC_INST_ID_,
BUSINESS_KEY_,
PROC_DEF_ID_,
ACT_ID_,
ACT_INST_ID_,
IS_ACTIVE_,
IS_CONCURRENT_,
IS_SCOPE_,
IS_EVENT_SCOPE_,
PARENT_ID_,
SUPER_EXEC_,
SUPER_CASE_EXEC_,
CASE_INST_ID_,
SUSPENSION_STATE_,
CACHED_ENT_STATE_,
SEQUENCE_COUNTER_,
TENANT_ID_,
REV_
)
values
(
#{id ,jdbcType=VARCHAR},
#{rootProcessInstanceIdRaw, jdbcType=VARCHAR},
#{processInstanceId, jdbcType=VARCHAR},
#{businessKeyWithoutCascade, jdbcType=VARCHAR},
#{processDefinitionId ,jdbcType=VARCHAR},
#{activityId ,jdbcType=VARCHAR},
#{activityInstanceId ,jdbcType=VARCHAR},
#{isActive ,jdbcType=BOOLEAN},
#{isConcurrent ,jdbcType=BOOLEAN},
#{isScope ,jdbcType=BOOLEAN},
#{isEventScope ,jdbcType=BOOLEAN},
#{parentId, jdbcType=VARCHAR},
#{superExecutionId, jdbcType=VARCHAR},
#{superCaseExecutionId, jdbcType=VARCHAR},
#{caseInstanceId, jdbcType=VARCHAR},
#{suspensionState, jdbcType=INTEGER},
#{cachedEntityState, jdbcType=INTEGER},
#{sequenceCounter, jdbcType=BIGINT},
#{tenantId, jdbcType=VARCHAR},
1
)
</insert>
<!-- EXECUTION UPDATE -->
<update id="updateExecution" parameterType="org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity">
update ${prefix}ACT_RU_EXECUTION set
REV_ = #{revisionNext, jdbcType=INTEGER},
PROC_DEF_ID_ = #{processDefinitionId, jdbcType=VARCHAR},
BUSINESS_KEY_ = #{businessKeyWithoutCascade, jdbcType=VARCHAR},
ACT_ID_ = #{activityId, jdbcType=VARCHAR},
ACT_INST_ID_ = #{activityInstanceId, jdbcType=VARCHAR},
IS_ACTIVE_ = #{isActive, jdbcType=BOOLEAN},
IS_CONCURRENT_ = #{isConcurrent, jdbcType=BOOLEAN},
IS_SCOPE_ = #{isScope, jdbcType=BOOLEAN},
IS_EVENT_SCOPE_ = #{isEventScope, jdbcType=BOOLEAN},
PARENT_ID_ = #{parentId, jdbcType=VARCHAR},
SUPER_EXEC_ = #{superExecutionId, jdbcType=VARCHAR},
SUSPENSION_STATE_ = #{suspensionState, jdbcType=INTEGER},
CACHED_ENT_STATE_ = #{cachedEntityState, jdbcType=INTEGER},
SEQUENCE_COUNTER_ = #{sequenceCounter, jdbcType=BIGINT},
TENANT_ID_ = #{tenantId, jdbcType=BIGINT}
where ID_ = #{id, jdbcType=VARCHAR}
and REV_ = #{revision, jdbcType=INTEGER}
</update>
<update id="updateExecutionSuspensionStateByParameters" parameterType="org.camunda.bpm.engine.impl.db.ListQueryParameterObject">
update ${prefix}ACT_RU_EXECUTION set
REV_ = 1 + REV_ ,
SUSPENSION_STATE_ = #{parameter.suspensionState, jdbcType=INTEGER}
<where>
<if test="parameter.processInstanceId != null">
PROC_INST_ID_ = #{parameter.processInstanceId, jdbcType=VARCHAR}
</if>
<if test="parameter.processDefinitionId != null">
and PROC_DEF_ID_ = #{parameter.processDefinitionId, jdbcType=VARCHAR}
</if>
<if test="parameter.processDefinitionKey != null">
and PROC_DEF_ID_ IN (
SELECT ID_
FROM ${prefix}ACT_RE_PROCDEF PD
WHERE PD.KEY_ = #{parameter.processDefinitionKey, jdbcType=VARCHAR}
<if test="parameter.isTenantIdSet">
<if test="parameter.tenantId != null">
and PD.TENANT_ID_ = #{parameter.tenantId, jdbcType=VARCHAR}
</if>
<if test="parameter.tenantId == null">
and PD.TENANT_ID_ is null
</if>
</if>
)
<bind name="columnPrefix" value="''"/>
<include refid="org.camunda.bpm.engine.impl.persistence.entity.TenantEntity.queryTenantCheckWithPrefix" />
</if>
</where>
</update>
<!-- EXECUTION DELETE -->
<delete id="deleteExecution" parameterType="org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity">
delete from ${prefix}ACT_RU_EXECUTION where ID_ = #{id} and REV_ = #{revision}
</delete>
<!-- EXECUTION RESULTMAP -->
<resultMap id="executionResultMap" type="org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity">
<id property="id" column="ID_" jdbcType="VARCHAR" />
<result property="revision" column="REV_" jdbcType="INTEGER" />
<result property="rootProcessInstanceId" column="ROOT_PROC_INST_ID_" jdbcType="VARCHAR"/>
<result property="processInstanceId" column="PROC_INST_ID_" jdbcType="VARCHAR" />
<result property="businessKey" column="BUSINESS_KEY_" jdbcType="VARCHAR" />
<result property="processDefinitionId" column="PROC_DEF_ID_" jdbcType="VARCHAR" />
<result property="activityId" column="ACT_ID_" jdbcType="VARCHAR" />
<result property="activityInstanceId" column="ACT_INST_ID_" jdbcType="VARCHAR" />
<result property="isActive" column="IS_ACTIVE_" jdbcType="BOOLEAN" />
<result property="isConcurrent" column="IS_CONCURRENT_" jdbcType="BOOLEAN" />
<result property="isScope" column="IS_SCOPE_" jdbcType="BOOLEAN" />
<result property="isEventScope" column="IS_EVENT_SCOPE_" jdbcType="BOOLEAN" />
<result property="parentId" column="PARENT_ID_" jdbcType="VARCHAR" />
<result property="superExecutionId" column="SUPER_EXEC_" jdbcType="VARCHAR" />
<result property="superCaseExecutionId" column="SUPER_CASE_EXEC_" jdbcType="VARCHAR" />
<result property="caseInstanceId" column="CASE_INST_ID_" jdbcType="VARCHAR" />
<result property="suspensionState" column="SUSPENSION_STATE_" jdbcType="INTEGER"/>
<result property="cachedEntityState" column="CACHED_ENT_STATE_" jdbcType="INTEGER"/>
<result property="sequenceCounter" column="SEQUENCE_COUNTER_" jdbcType="BIGINT"/>
<result property="tenantId" column="TENANT_ID_" jdbcType="VARCHAR"/>
</resultMap>
<!-- EXECUTION SELECT -->
<select id="selectExecution" parameterType="string" resultMap="executionResultMap">
select * from ${prefix}ACT_RU_EXECUTION where ID_ = #{id}
</select>
<select id="selectExecutionsByParentExecutionId" parameterType="org.camunda.bpm.engine.impl.db.ListQueryParameterObject" resultMap="executionResultMap">
select * from ${prefix}ACT_RU_EXECUTION
where PARENT_ID_ = #{parameter}
</select>
<select id="selectExecutionsByProcessInstanceId" parameterType="org.camunda.bpm.engine.impl.db.ListQueryParameterObject" resultMap="executionResultMap">
select * from ${prefix}ACT_RU_EXECUTION
where PROC_INST_ID_ = #{parameter}
</select>
<select id="selectProcessInstanceIdsByProcessDefinitionId" parameterType="org.camunda.bpm.engine.impl.db.ListQueryParameterObject" resultType="string">
select ID_
from ${prefix}ACT_RU_EXECUTION
where PROC_DEF_ID_ = #{parameter} and PARENT_ID_ is null
</select>
<select id="selectExecutionsByQueryCriteria" parameterType="org.camunda.bpm.engine.impl.ExecutionQueryImpl" resultMap="executionResultMap">
<include refid="org.camunda.bpm.engine.impl.persistence.entity.Commons.bindOrderBy"/>
${limitBefore}
select ${distinct} RES.*
${limitBetween}
<include refid="org.camunda.bpm.engine.impl.persistence.entity.Commons.orderBySelection"/>
<include refid="selectExecutionsByQueryCriteriaSql"/>
${orderBy}
${limitAfter}
</select>
<select id="selectExecutionCountByQueryCriteria" parameterType="org.camunda.bpm.engine.impl.ExecutionQueryImpl" resultType="long">
${countDistinctBeforeStart} RES.ID_ ${countDistinctBeforeEnd}
<include refid="selectExecutionsByQueryCriteriaSql"/>
${countDistinctAfterEnd}
</select>
<select id="selectProcessInstanceByQueryCriteria" parameterType="org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl" resultMap="executionResultMap">
<include refid="org.camunda.bpm.engine.impl.persistence.entity.Commons.bindOrderBy"/>
${limitBefore}
select ${distinct} RES.*
${limitBetween}
<include refid="org.camunda.bpm.engine.impl.persistence.entity.Commons.orderBySelection"/>
<include refid="selectProcessInstanceByQueryCriteriaSql"/>
${orderBy}
${limitAfter}
</select>
<select id="selectProcessInstanceCountByQueryCriteria" parameterType="org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl" resultType="long">
${countDistinctBeforeStart} RES.ID_ ${countDistinctBeforeEnd}
<include refid="selectProcessInstanceByQueryCriteriaSql"/>
${countDistinctAfterEnd}
</select>
<select id="selectProcessInstanceIdsByQueryCriteria" parameterType="org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl" resultType="string">
select distinct RES.ID_
<include refid="selectProcessInstanceByQueryCriteriaSql"/>
</select>
<sql id="selectProcessInstanceByQueryCriteriaSql">
from ${prefix}ACT_RU_EXECUTION RES
<bind name="INC_JOIN" value="false" />
<bind name="EXE_JOIN" value="false" />
<bind name="JOIN_TYPE" value="'inner join'" />
<foreach collection="queries" item="query">
<if test="query.isOrQueryActive">
<bind name="JOIN_TYPE" value="'left join'" />
</if>
<if test="query != null && (query.withIncident || query.incidentType != null || query.incidentId != null || query.incidentMessage != null || query.incidentMessageLike != null)">
<bind name="INC_JOIN" value="true" />
</if>
<if test="query != null && (query.activityIds != null && query.activityIds.length > 0)">
<bind name="EXE_JOIN" value="true" />
</if>
</foreach>
<if test="INC_JOIN">
${JOIN_TYPE} ${prefix}ACT_RU_INCIDENT INC on RES.ID_ = INC.PROC_INST_ID_
</if>
<if test="EXE_JOIN">
${JOIN_TYPE} ${prefix}ACT_RU_EXECUTION EXE on RES.ID_ = EXE.PROC_INST_ID_
</if>
inner join ${prefix}ACT_RE_PROCDEF P on RES.PROC_DEF_ID_ = P.ID_
<if test="authCheck.shouldPerformAuthorizatioCheck && !authCheck.revokeAuthorizationCheckEnabled && authCheck.authUserId != null">
<include refid="org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity.authCheckJoinWithoutOnClause" />
AUTH ON (AUTH.RESOURCE_ID_ in (RES.ID_, P.KEY_, '*'))
</if>
<where>
<foreach collection="queries" item="query" index="i">
<choose>
<when test="i == 0">
<bind name="queryType" value="'and'" />
</when>
<otherwise>
<bind name="queryType" value="'or'" />
</otherwise>
</choose>
and (
<trim suffixOverrides="and">
RES.PARENT_ID_ is null and
<trim prefix="(" prefixOverrides="or|and" suffix=")">
<if test="query.processDefinitionId != null">
${queryType} P.ID_ = #{query.processDefinitionId}
</if>
<if test="query.processDefinitionKey != null">
${queryType} P.KEY_ = #{query.processDefinitionKey}
</if>
<if test="query.processDefinitionKeys != null && query.processDefinitionKeys.length > 0">
${queryType} P.KEY_ in
<foreach item="item" index="index" collection="query.processDefinitionKeys"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="query.processDefinitionKeyNotIn != null && query.processDefinitionKeyNotIn.length > 0">
${queryType} P.KEY_ not in
<foreach item="item" index="index" collection="query.processDefinitionKeyNotIn"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="query.deploymentId != null">
${queryType} P.DEPLOYMENT_ID_ = #{query.deploymentId}
</if>
<if test="query.processInstanceId != null">
${queryType} RES.PROC_INST_ID_ = #{query.processInstanceId}
</if>
<if test="query.processInstanceIds != null and !query.processInstanceIds.isEmpty()">
${queryType}
<bind name="listOfIds" value="query.processInstanceIds" />
<bind name="fieldName" value="'RES.PROC_INST_ID_'" />
<include refid="org.camunda.bpm.engine.impl.persistence.entity.Commons.applyInForPaginatedCollection" />
</if>
<if test="query.businessKey != null">
${queryType} RES.BUSINESS_KEY_ = #{query.businessKey}
</if>
<if test="query.businessKeyLike != null">
${queryType} RES.BUSINESS_KEY_ like #{query.businessKeyLike} ESCAPE ${escapeChar}
</if>
<if test="query.superProcessInstanceId != null">
<!-- A sub process instance is stored under a certain *execution*, potentially nested.
A sub process instance is NOT stored under the process instance, hence the following: -->
${queryType} RES.SUPER_EXEC_ IN (select ID_ from ${prefix}ACT_RU_EXECUTION where PROC_INST_ID_ = #{query.superProcessInstanceId})
</if>
<if test="query.isRootProcessInstances == true">
${queryType} RES.SUPER_EXEC_ is null
</if>
<if test="query.isLeafProcessInstances">
and RES.ID_ not in (
select SUPER.PROC_INST_ID_ from ${prefix}ACT_RU_EXECUTION SUPER
inner join ${prefix}ACT_RU_EXECUTION CALLED on SUPER.ID_ = CALLED.SUPER_EXEC_ where CALLED.ID_ = CALLED.PROC_INST_ID_)
</if>
<if test="query.subProcessInstanceId != null">
${queryType} RES.ID_ = (select PROC_INST_ID_ from ${prefix}ACT_RU_EXECUTION where ID_ = (select SUPER_EXEC_ from ${prefix}ACT_RU_EXECUTION where ID_ = #{query.subProcessInstanceId}))
</if>
<if test="query.suspensionState != null">
${queryType} RES.SUSPENSION_STATE_ = #{query.suspensionState.stateCode}
</if>
<if test="query.caseInstanceId != null">
${queryType} RES.CASE_INST_ID_ = #{query.caseInstanceId}
</if>
<if test="query.superCaseInstanceId != null">
${queryType} RES.SUPER_CASE_EXEC_ IN (select ID_ from ${prefix}ACT_RU_CASE_EXECUTION where CASE_INST_ID_ = #{query.superCaseInstanceId})
</if>
<if test="query.subCaseInstanceId != null">
${queryType} RES.ID_ = (select PROC_INST_ID_ from ${prefix}ACT_RU_EXECUTION where ID_ = (select SUPER_EXEC_ from ${prefix}ACT_RU_CASE_EXECUTION where ID_ = #{query.subCaseInstanceId}))
</if>
<!-- PLEASE NOTE: If you change anything have a look into the HistoricVariableInstance & HistoricProcessInstance, the same query object is used there! -->
<foreach collection="query.queryVariableValues" index="index" item="queryVariableValue">
${queryType} EXISTS (
select
ID_
from
${prefix}ACT_RU_VARIABLE
WHERE
<bind name="varPrefix" value="''"/>
<include refid="org.camunda.bpm.engine.impl.persistence.entity.Commons.variableNameEqualsCaseInsensitive" />
<choose>
<when test="queryVariableValue.local">
and RES.ID_ = EXECUTION_ID_
</when>
<otherwise>
<!-- When process instance or case instance variable is queried for, taskId should be null -->
and TASK_ID_ is null and RES.PROC_INST_ID_ = PROC_INST_ID_
</otherwise>
</choose>
<bind name="varTypeField" value="'TYPE_'"/>
<if test="queryVariableValue.valueConditions != null">
and
<include refid="org.camunda.bpm.engine.impl.persistence.entity.Commons.variableValueConditions"/>
</if>
)
</foreach>
<if test="query.incidentType != null">
${queryType} INC.INCIDENT_TYPE_ = #{query.incidentType}
</if>
<if test="query.incidentId != null">
${queryType} INC.ID_ = #{query.incidentId}
</if>
<if test="query.incidentMessage != null">
${queryType} INC.INCIDENT_MSG_ = #{query.incidentMessage}
</if>
<if test="query.incidentMessageLike != null">
${queryType} INC.INCIDENT_MSG_ like #{query.incidentMessageLike} ESCAPE ${escapeChar}
</if>
<if test="query.isProcessDefinitionWithoutTenantId">
${queryType} P.TENANT_ID_ IS NULL
</if>
<if test="query.isTenantIdSet">
<if test="query.tenantIds != null && query.tenantIds.length > 0">
${queryType} RES.TENANT_ID_ in
<foreach item="tenantId" index="index" collection="query.tenantIds"
open="(" separator="," close=")">
#{tenantId}
</foreach>
</if>
<if test="query.tenantIds == null">
${queryType} RES.TENANT_ID_ is null
</if>
</if>
<if test="query.activityIds != null && query.activityIds.length > 0">
${queryType} (EXE.IS_EVENT_SCOPE_ = ${falseConstant}
and EXE.ACT_ID_ in
<foreach item="activityId" index="index" collection="query.activityIds"
open="(" separator="," close=")">
#{activityId}
</foreach>
)
</if>
</trim>
</trim>
)
</foreach>
<include refid="org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity.queryAuthorizationCheck" />
<include refid="org.camunda.bpm.engine.impl.persistence.entity.TenantEntity.queryTenantCheck" />
</where>
</sql>
<sql id="selectExecutionsByQueryCriteriaSql">
from ${prefix}ACT_RU_EXECUTION RES
<if test="businessKey != null">
inner join ${prefix}ACT_RU_EXECUTION INST on RES.PROC_INST_ID_ = INST.ID_
</if>
<if test="incidentType != null || incidentId != null || incidentMessage != null || incidentMessageLike != null">
inner join ${prefix}ACT_RU_INCIDENT INC on RES.ID_ = INC.EXECUTION_ID_
</if>
inner join ${prefix}ACT_RE_PROCDEF P on RES.PROC_DEF_ID_ = P.ID_
<if test="authCheck.shouldPerformAuthorizatioCheck && !authCheck.revokeAuthorizationCheckEnabled && authCheck.authUserId != null">
<include refid="org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity.authCheckJoinWithoutOnClause" />
AUTH ON (AUTH.RESOURCE_ID_ in (RES.PROC_INST_ID_, P.KEY_, '*'))
</if>
<where>
<if test="processDefinitionId != null">
and P.ID_ = #{processDefinitionId}
</if>
<if test="processDefinitionKey != null">
and P.KEY_ = #{processDefinitionKey}
</if>
<if test="executionId != null">
and RES.ID_ = #{executionId}
</if>
<if test="processInstanceId != null">
and RES.PROC_INST_ID_ = #{processInstanceId}
</if>
<if test="businessKey != null">
and INST.BUSINESS_KEY_ = #{businessKey}
</if>
<if test="activityId != null">
and RES.ACT_ID_ = #{activityId}
</if>
<if test="suspensionState != null">
and RES.SUSPENSION_STATE_ = #{suspensionState.stateCode}
</if>
<!-- PLEASE NOTE: If you change anything have a look into the HistoricVariableInstance & HistoricProcessInstance, the same query object is used there! -->
<foreach collection="queryVariableValues" index="index" item="queryVariableValue">
and EXISTS (
select
ID_
from
${prefix}ACT_RU_VARIABLE
WHERE
<bind name="varPrefix" value="''"/>
<include refid="org.camunda.bpm.engine.impl.persistence.entity.Commons.variableNameEqualsCaseInsensitive" />
<choose>
<when test="queryVariableValue.local">
and RES.ID_ = EXECUTION_ID_
</when>
<otherwise>
<!-- When process instance or case instance variable is queried for, taskId should be null -->
and TASK_ID_ is null and RES.PROC_INST_ID_ = PROC_INST_ID_
</otherwise>
</choose>
<bind name="varTypeField" value="'TYPE_'"/>
<if test="queryVariableValue.valueConditions != null">
and
<include refid="org.camunda.bpm.engine.impl.persistence.entity.Commons.variableValueConditions"/>
</if>
)
</foreach>
<!-- event subscriptions -->
<if test="eventSubscriptions != null">
<foreach collection="eventSubscriptions" index="index" item="eventSubscriptionValue">
and exists (select ID_ from ${prefix}ACT_RU_EVENT_SUBSCR EVT where
EVT.EXECUTION_ID_ = RES.ID_ and
EVT.EVENT_TYPE_ = #{eventSubscriptionValue.eventType}
<if test = "eventSubscriptionValue.eventName != null">
and EVT.EVENT_NAME_ = #{eventSubscriptionValue.eventName}
</if>
)
</foreach>
</if>
<if test="incidentType != null">
and INC.INCIDENT_TYPE_ = #{incidentType}
</if>
<if test="incidentId != null">
and INC.ID_ = #{incidentId}
</if>
<if test="incidentMessage != null">
and INC.INCIDENT_MSG_ = #{incidentMessage}
</if>
<if test="incidentMessageLike != null">
and INC.INCIDENT_MSG_ like #{incidentMessageLike} ESCAPE ${escapeChar}
</if>
<if test="isTenantIdSet">
<if test="tenantIds != null && tenantIds.length > 0">
and RES.TENANT_ID_ in
<foreach item="tenantId" index="index" collection="tenantIds"
open="(" separator="," close=")">
#{tenantId}
</foreach>
</if>
<if test="tenantIds == null">
and RES.TENANT_ID_ is null
</if>
</if>
<include refid="org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity.queryAuthorizationCheck" />
<include refid="org.camunda.bpm.engine.impl.persistence.entity.TenantEntity.queryTenantCheck" />
</where>
</sql>
<select id="selectSubProcessInstanceBySuperExecutionId" parameterType="string" resultMap="executionResultMap">
select *
from ${prefix}ACT_RU_EXECUTION
where SUPER_EXEC_ = #{parameter}
</select>
<select id="selectSubProcessInstanceBySuperCaseExecutionId" parameterType="string" resultMap="executionResultMap">
select *
from ${prefix}ACT_RU_EXECUTION
where SUPER_CASE_EXEC_ = #{parameter}
</select>
<select id="selectExecutionByNativeQuery" parameterType="java.util.Map" resultMap="executionResultMap">
<if test="resultType == 'LIST_PAGE'">
${limitBefore}
</if>
${sql}
<if test="resultType == 'LIST_PAGE'">
${limitAfter}
</if>
</select>
<select id="selectExecutionByNativeQuery_mssql_or_db2" parameterType="java.util.Map" resultMap="executionResultMap">
<if test="resultType == 'LIST_PAGE'">
${limitBeforeNativeQuery}
</if>
${sql}
<if test="resultType == 'LIST_PAGE'">
${limitAfter}
</if>
</select>
<select id="selectExecutionCountByNativeQuery" parameterType="java.util.Map" resultType="long">
${sql}
</select>
</mapper>