Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.flowable.db.mapping.entity.Execution.xml Maven / Gradle / Ivy
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl">
<!-- EXECUTION INSERT -->
<insert id="insertExecution" parameterType="org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl">
insert into ${prefix}ACT_RU_EXECUTION (ID_, REV_, PROC_INST_ID_, BUSINESS_KEY_, PROC_DEF_ID_, ACT_ID_, IS_ACTIVE_, IS_CONCURRENT_,
IS_SCOPE_,IS_EVENT_SCOPE_, IS_MI_ROOT_, PARENT_ID_, SUPER_EXEC_, ROOT_PROC_INST_ID_, SUSPENSION_STATE_,
TENANT_ID_, NAME_, START_ACT_ID_, START_TIME_, START_USER_ID_, IS_COUNT_ENABLED_, EVT_SUBSCR_COUNT_,
TASK_COUNT_, JOB_COUNT_, TIMER_JOB_COUNT_, SUSP_JOB_COUNT_, DEADLETTER_JOB_COUNT_, EXTERNAL_WORKER_JOB_COUNT_, VAR_COUNT_, ID_LINK_COUNT_,
CALLBACK_ID_, CALLBACK_TYPE_, REFERENCE_ID_, REFERENCE_TYPE_, PROPAGATED_STAGE_INST_ID_)
values (
#{id ,jdbcType=VARCHAR},
1, #{processInstanceId, jdbcType=VARCHAR},
#{businessKey, jdbcType=VARCHAR},
#{processDefinitionId ,jdbcType=VARCHAR},
#{activityId ,jdbcType=VARCHAR},
#{isActive ,jdbcType=BOOLEAN},
#{isConcurrent ,jdbcType=BOOLEAN},
#{isScope ,jdbcType=BOOLEAN},
#{isEventScope ,jdbcType=BOOLEAN},
#{isMultiInstanceRoot, jdbcType=BOOLEAN},
#{parentId, jdbcType=VARCHAR},
#{superExecutionId, jdbcType=VARCHAR},
#{rootProcessInstanceId, jdbcType=VARCHAR},
#{suspensionState, jdbcType=INTEGER},
#{tenantId, jdbcType=VARCHAR},
#{name, jdbcType=VARCHAR},
#{startActivityId, jdbcType=VARCHAR},
#{startTime, jdbcType=TIMESTAMP},
#{startUserId, jdbcType=VARCHAR},
#{isCountEnabled, jdbcType=BOOLEAN},
#{eventSubscriptionCount, jdbcType=INTEGER},
#{taskCount, jdbcType=INTEGER},
#{jobCount, jdbcType=INTEGER},
#{timerJobCount, jdbcType=INTEGER},
#{suspendedJobCount, jdbcType=INTEGER},
#{deadLetterJobCount, jdbcType=INTEGER},
#{externalWorkerJobCount, jdbcType=INTEGER},
#{variableCount, jdbcType=INTEGER},
#{identityLinkCount, jdbcType=INTEGER},
#{callbackId, jdbcType=VARCHAR},
#{callbackType, jdbcType=VARCHAR},
#{referenceId, jdbcType=VARCHAR},
#{referenceType, jdbcType=VARCHAR},
#{propagatedStageInstanceId, jdbcType=VARCHAR}
)
</insert>
<insert id="bulkInsertExecution" parameterType="java.util.List">
insert into ${prefix}ACT_RU_EXECUTION (ID_, REV_, PROC_INST_ID_, BUSINESS_KEY_, PROC_DEF_ID_, ACT_ID_, IS_ACTIVE_, IS_CONCURRENT_,
IS_SCOPE_,IS_EVENT_SCOPE_, IS_MI_ROOT_, PARENT_ID_, SUPER_EXEC_, ROOT_PROC_INST_ID_, SUSPENSION_STATE_,
TENANT_ID_, NAME_, START_ACT_ID_, START_TIME_, START_USER_ID_, IS_COUNT_ENABLED_, EVT_SUBSCR_COUNT_,
TASK_COUNT_, JOB_COUNT_, TIMER_JOB_COUNT_, SUSP_JOB_COUNT_, DEADLETTER_JOB_COUNT_, EXTERNAL_WORKER_JOB_COUNT_, VAR_COUNT_, ID_LINK_COUNT_,
CALLBACK_ID_, CALLBACK_TYPE_, REFERENCE_ID_, REFERENCE_TYPE_, PROPAGATED_STAGE_INST_ID_)
values
<foreach collection="list" item="execution" index="index" separator=",">
(#{execution.id ,jdbcType=VARCHAR},
1, #{execution.processInstanceId, jdbcType=VARCHAR},
#{execution.businessKey, jdbcType=VARCHAR},
#{execution.processDefinitionId ,jdbcType=VARCHAR},
#{execution.activityId ,jdbcType=VARCHAR},
#{execution.isActive ,jdbcType=BOOLEAN},
#{execution.isConcurrent ,jdbcType=BOOLEAN},
#{execution.isScope ,jdbcType=BOOLEAN},
#{execution.isEventScope ,jdbcType=BOOLEAN},
#{execution.isMultiInstanceRoot, jdbcType=BOOLEAN},
#{execution.parentId, jdbcType=VARCHAR},
#{execution.superExecutionId, jdbcType=VARCHAR},
#{execution.rootProcessInstanceId, jdbcType=VARCHAR},
#{execution.suspensionState, jdbcType=INTEGER},
#{execution.tenantId, jdbcType=VARCHAR},
#{execution.name, jdbcType=VARCHAR},
#{execution.startActivityId, jdbcType=VARCHAR},
#{execution.startTime, jdbcType=TIMESTAMP},
#{execution.startUserId, jdbcType=VARCHAR},
#{execution.isCountEnabled, jdbcType=BOOLEAN},
#{execution.eventSubscriptionCount, jdbcType=INTEGER},
#{execution.taskCount, jdbcType=INTEGER},
#{execution.jobCount, jdbcType=INTEGER},
#{execution.timerJobCount, jdbcType=INTEGER},
#{execution.suspendedJobCount, jdbcType=INTEGER},
#{execution.deadLetterJobCount, jdbcType=INTEGER},
#{execution.externalWorkerJobCount, jdbcType=INTEGER},
#{execution.variableCount, jdbcType=INTEGER},
#{execution.identityLinkCount, jdbcType=INTEGER},
#{execution.callbackId, jdbcType=VARCHAR},
#{execution.callbackType, jdbcType=VARCHAR},
#{execution.referenceId, jdbcType=VARCHAR},
#{execution.referenceType, jdbcType=VARCHAR},
#{execution.propagatedStageInstanceId, jdbcType=VARCHAR}
)
</foreach>
</insert>
<insert id="bulkInsertExecution" databaseId="oracle" parameterType="java.util.List">
INSERT ALL
<foreach collection="list" item="execution" index="index">
into ${prefix}ACT_RU_EXECUTION (ID_, REV_, PROC_INST_ID_, BUSINESS_KEY_, PROC_DEF_ID_, ACT_ID_, IS_ACTIVE_, IS_CONCURRENT_,
IS_SCOPE_,IS_EVENT_SCOPE_, IS_MI_ROOT_, PARENT_ID_, SUPER_EXEC_, ROOT_PROC_INST_ID_, SUSPENSION_STATE_,
TENANT_ID_, NAME_, START_ACT_ID_, START_TIME_, START_USER_ID_, IS_COUNT_ENABLED_, EVT_SUBSCR_COUNT_,
TASK_COUNT_, JOB_COUNT_, TIMER_JOB_COUNT_, SUSP_JOB_COUNT_, DEADLETTER_JOB_COUNT_, EXTERNAL_WORKER_JOB_COUNT_, VAR_COUNT_, ID_LINK_COUNT_,
CALLBACK_ID_, CALLBACK_TYPE_, REFERENCE_ID_, REFERENCE_TYPE_, PROPAGATED_STAGE_INST_ID_) VALUES
(
#{execution.id ,jdbcType=VARCHAR},
1, #{execution.processInstanceId, jdbcType=VARCHAR},
#{execution.businessKey, jdbcType=VARCHAR},
#{execution.processDefinitionId ,jdbcType=VARCHAR},
#{execution.activityId ,jdbcType=VARCHAR},
#{execution.isActive ,jdbcType=BOOLEAN},
#{execution.isConcurrent ,jdbcType=BOOLEAN},
#{execution.isScope ,jdbcType=BOOLEAN},
#{execution.isEventScope ,jdbcType=BOOLEAN},
#{execution.isMultiInstanceRoot, jdbcType=BOOLEAN},
#{execution.parentId, jdbcType=VARCHAR},
#{execution.superExecutionId, jdbcType=VARCHAR},
#{execution.rootProcessInstanceId, jdbcType=VARCHAR},
#{execution.suspensionState, jdbcType=INTEGER},
#{execution.tenantId, jdbcType=VARCHAR},
#{execution.name, jdbcType=VARCHAR},
#{execution.startActivityId, jdbcType=VARCHAR},
#{execution.startTime, jdbcType=TIMESTAMP},
#{execution.startUserId, jdbcType=VARCHAR},
#{execution.isCountEnabled, jdbcType=BOOLEAN},
#{execution.eventSubscriptionCount, jdbcType=INTEGER},
#{execution.taskCount, jdbcType=INTEGER},
#{execution.jobCount, jdbcType=INTEGER},
#{execution.timerJobCount, jdbcType=INTEGER},
#{execution.suspendedJobCount, jdbcType=INTEGER},
#{execution.deadLetterJobCount, jdbcType=INTEGER},
#{execution.externalWorkerJobCount, jdbcType=INTEGER},
#{execution.variableCount, jdbcType=INTEGER},
#{execution.identityLinkCount, jdbcType=INTEGER},
#{execution.callbackId, jdbcType=VARCHAR},
#{execution.callbackType, jdbcType=VARCHAR},
#{execution.referenceId, jdbcType=VARCHAR},
#{execution.referenceType, jdbcType=VARCHAR},
#{execution.propagatedStageInstanceId, jdbcType=VARCHAR}
)
</foreach>
SELECT * FROM dual
</insert>
<!-- EXECUTION UPDATE -->
<update id="updateExecution" parameterType="org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl">
update ${prefix}ACT_RU_EXECUTION
<set>
REV_ = #{revisionNext, jdbcType=INTEGER},
<if test="originalPersistentState.businessKey != businessKey">
BUSINESS_KEY_ = #{businessKey, jdbcType=VARCHAR},
</if>
<if test="originalPersistentState.processDefinitionId != processDefinitionId">
PROC_DEF_ID_ = #{processDefinitionId, jdbcType=VARCHAR},
</if>
<if test="originalPersistentState.activityId != activityId">
ACT_ID_ = #{activityId, jdbcType=VARCHAR},
</if>
<if test="originalPersistentState.isActive != isActive">
IS_ACTIVE_ = #{isActive, jdbcType=BOOLEAN},
</if>
<if test="originalPersistentState.isConcurrent != isConcurrent">
IS_CONCURRENT_ = #{isConcurrent, jdbcType=BOOLEAN},
</if>
<if test="originalPersistentState.isScope != isScope">
IS_SCOPE_ = #{isScope, jdbcType=BOOLEAN},
</if>
<if test="originalPersistentState.isEventScope != isEventScope">
IS_EVENT_SCOPE_ = #{isEventScope, jdbcType=BOOLEAN},
</if>
<if test="originalPersistentState.isMultiInstanceRoot != isMultiInstanceRoot">
IS_MI_ROOT_ = #{isMultiInstanceRoot, jdbcType=BOOLEAN},
</if>
<if test="originalPersistentState.parentId != parentId">
PARENT_ID_ = #{parentId, jdbcType=VARCHAR},
</if>
<if test="originalPersistentState.superExecutionId != superExecutionId">
SUPER_EXEC_ = #{superExecutionId, jdbcType=VARCHAR},
</if>
<if test="originalPersistentState.rootProcessInstanceId != rootProcessInstanceId">
ROOT_PROC_INST_ID_ = #{rootProcessInstanceId, jdbcType=VARCHAR},
</if>
<if test="originalPersistentState.suspensionState != suspensionState">
SUSPENSION_STATE_ = #{suspensionState, jdbcType=INTEGER},
</if>
<if test="originalPersistentState.name != name">
NAME_ = #{name, jdbcType=VARCHAR},
</if>
<if test="originalPersistentState.isCountEnabled != isCountEnabled">
IS_COUNT_ENABLED_ = #{isCountEnabled, jdbcType=BOOLEAN},
</if>
<if test="originalPersistentState.eventSubscriptionCount != eventSubscriptionCount">
EVT_SUBSCR_COUNT_ = #{eventSubscriptionCount, jdbcType=INTEGER},
</if>
<if test="originalPersistentState.taskCount != taskCount">
TASK_COUNT_ = #{taskCount, jdbcType=INTEGER},
</if>
<if test="originalPersistentState.jobCount != jobCount">
JOB_COUNT_ = #{jobCount, jdbcType=INTEGER},
</if>
<if test="originalPersistentState.timerJobCount != timerJobCount">
TIMER_JOB_COUNT_ = #{timerJobCount, jdbcType=INTEGER},
</if>
<if test="originalPersistentState.suspendedJobCount != suspendedJobCount">
SUSP_JOB_COUNT_ = #{suspendedJobCount, jdbcType=INTEGER},
</if>
<if test="originalPersistentState.deadLetterJobCount != deadLetterJobCount">
DEADLETTER_JOB_COUNT_ = #{deadLetterJobCount, jdbcType=INTEGER},
</if>
<if test="originalPersistentState.externalWorkerJobCount != externalWorkerJobCount">
EXTERNAL_WORKER_JOB_COUNT_ = #{externalWorkerJobCount, jdbcType=INTEGER},
</if>
<if test="originalPersistentState.variableCount != variableCount">
VAR_COUNT_ = #{variableCount, jdbcType=INTEGER},
</if>
<if test="originalPersistentState.identityLinkCount != identityLinkCount">
ID_LINK_COUNT_ = #{identityLinkCount, jdbcType=INTEGER},
</if>
<if test="originalPersistentState.callbackId != callbackId">
CALLBACK_ID_ = #{callbackId, jdbcType=VARCHAR},
</if>
<if test="originalPersistentState.callbackType != callbackType">
CALLBACK_ID_ = #{callbackType, jdbcType=VARCHAR},
</if>
<if test="originalPersistentState.referenceId != referenceId">
REFERENCE_ID_ = #{referenceId, jdbcType=VARCHAR},
</if>
<if test="originalPersistentState.referenceType != referenceType">
REFERENCE_TYPE_ = #{referenceType, jdbcType=VARCHAR},
</if>
<if test="originalPersistentState.propagatedStageInstanceId != propagatedStageInstanceId">
PROPAGATED_STAGE_INST_ID_ = #{propagatedStageInstanceId, jdbcType=VARCHAR},
</if>
</set>
where ID_ = #{id, jdbcType=VARCHAR}
and REV_ = #{revision, jdbcType=INTEGER}
</update>
<update id="updateExecutionTenantIdForDeployment" parameterType="java.util.Map">
update ${prefix}ACT_RU_EXECUTION set
TENANT_ID_ = #{tenantId, jdbcType=VARCHAR}
where
ID_ in (
SELECT E.ID_ from ${prefix}ACT_RU_EXECUTION E
inner join ${prefix}ACT_RE_PROCDEF P on E.PROC_DEF_ID_ = P.ID_
inner join ${prefix}ACT_RE_DEPLOYMENT D on P.DEPLOYMENT_ID_ = D.ID_
where D.ID_ = #{deploymentId, jdbcType=VARCHAR}
)
</update>
<!-- See http://stackoverflow.com/questions/4429319/you-cant-specify-target-table-for-update-in-from-clause
Tested this on MySQL 5.6: does NOT use a temporary table (so good, performance) -->
<update id="updateExecutionTenantIdForDeployment" databaseId="mysql" parameterType="java.util.Map">
update ${prefix}ACT_RU_EXECUTION set
TENANT_ID_ = #{tenantId, jdbcType=VARCHAR}
where
ID_ in (
SELECT tempExecution.tempId
FROM (
SELECT E.ID_ as tempId
FROM ${prefix}ACT_RU_EXECUTION E
inner join ${prefix}ACT_RE_PROCDEF P on E.PROC_DEF_ID_ = P.ID_
inner join ${prefix}ACT_RE_DEPLOYMENT D on P.DEPLOYMENT_ID_ = D.ID_
where D.ID_ = #{deploymentId, jdbcType=VARCHAR}
) AS tempExecution
)
</update>
<update id="updateProcessInstanceLockTime" parameterType="java.util.Map">
update ${prefix}ACT_RU_EXECUTION
set
LOCK_TIME_ = #{lockTime, jdbcType=TIMESTAMP},
LOCK_OWNER_ = #{lockOwner, jdbcType=VARCHAR}
where ID_ = #{id}
and (LOCK_TIME_ is null OR LOCK_TIME_ < #{expirationTime, jdbcType=TIMESTAMP})
</update>
<update id="clearProcessInstanceLockTime" parameterType="java.util.Map">
update ${prefix}ACT_RU_EXECUTION
set
LOCK_TIME_ = null,
LOCK_OWNER_ = null
where ID_ = #{id}
</update>
<update id="clearAllProcessInstanceLockTimes" parameterType="java.util.Map">
update ${prefix}ACT_RU_EXECUTION
set
LOCK_TIME_ = null,
LOCK_OWNER_ = null
where LOCK_OWNER_ = #{lockOwner, jdbcType=VARCHAR}
</update>
<update id="updateExecutionRelatedEntityCountEnabled" parameterType="boolean">
update ${prefix}ACT_RU_EXECUTION
set IS_COUNT_ENABLED_ = #{parameter, jdbcType=BOOLEAN}
</update>
<!-- EXECUTION DELETE -->
<delete id="deleteExecution" parameterType="org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl">
delete from ${prefix}ACT_RU_EXECUTION where ID_ = #{id} and REV_ = #{revision}
</delete>
<delete id="bulkDeleteExecution" parameterType="java.util.Collection">
delete from ${prefix}ACT_RU_EXECUTION where
<foreach item="execution" collection="list" index="index" separator=" or ">
ID_ = #{execution.id, jdbcType=VARCHAR}
</foreach>
</delete>
<!-- EXECUTION RESULTMAP -->
<resultMap id="executionResultMap" type="org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl">
<id property="id" column="ID_" jdbcType="VARCHAR" />
<result property="revision" column="REV_" jdbcType="INTEGER" />
<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="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="isMultiInstanceRoot" column="IS_MI_ROOT_" jdbcType="BOOLEAN" />
<result property="parentId" column="PARENT_ID_" jdbcType="VARCHAR" />
<result property="superExecutionId" column="SUPER_EXEC_" jdbcType="VARCHAR" />
<result property="rootProcessInstanceId" column="ROOT_PROC_INST_ID_" jdbcType="VARCHAR" />
<result property="suspensionState" column="SUSPENSION_STATE_" jdbcType="INTEGER"/>
<result property="tenantId" column="TENANT_ID_" jdbcType="VARCHAR" />
<result property="name" column="NAME_" jdbcType="VARCHAR" />
<result property="startActivityId" column="START_ACT_ID_" jdbcType="VARCHAR" />
<result property="startTime" column="START_TIME_" jdbcType="TIMESTAMP" />
<result property="startUserId" column="START_USER_ID_" jdbcType="VARCHAR" />
<result property="isCountEnabled" column="IS_COUNT_ENABLED_" jdbcType="BOOLEAN" />
<result property="eventSubscriptionCount" column="EVT_SUBSCR_COUNT_" jdbcType="INTEGER" />
<result property="taskCount" column="TASK_COUNT_" jdbcType="INTEGER" />
<result property="jobCount" column="JOB_COUNT_" jdbcType="INTEGER" />
<result property="timerJobCount" column="TIMER_JOB_COUNT_" jdbcType="INTEGER" />
<result property="suspendedJobCount" column="SUSP_JOB_COUNT_" jdbcType="INTEGER" />
<result property="deadLetterJobCount" column="DEADLETTER_JOB_COUNT_" jdbcType="INTEGER" />
<result property="externalWorkerJobCount" column="EXTERNAL_WORKER_JOB_COUNT_" jdbcType="INTEGER" />
<result property="variableCount" column="VAR_COUNT_" jdbcType="INTEGER" />
<result property="identityLinkCount" column="ID_LINK_COUNT_" jdbcType="INTEGER" />
<result property="callbackId" column="CALLBACK_ID_" jdbcType="VARCHAR" />
<result property="callbackType" column="CALLBACK_TYPE_" jdbcType="VARCHAR" />
<result property="referenceId" column="REFERENCE_ID_" jdbcType="VARCHAR" />
<result property="referenceType" column="REFERENCE_TYPE_" jdbcType="VARCHAR" />
<result property="propagatedStageInstanceId" column="PROPAGATED_STAGE_INST_ID_" jdbcType="VARCHAR" />
</resultMap>
<resultMap id="processInstanceResultMap" type="org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl">
<id property="id" column="ID_" jdbcType="VARCHAR" />
<result property="revision" column="REV_" jdbcType="INTEGER" />
<result property="processInstanceId" column="PROC_INST_ID_" jdbcType="VARCHAR" />
<result property="businessKey" column="BUSINESS_KEY_" jdbcType="VARCHAR" />
<!-- Lowercase 'columns', as they are filled in during a query and are not mapped directly to a table column -->
<result property="processDefinitionId" column="PROC_DEF_ID_" jdbcType="VARCHAR" />
<result property="processDefinitionName" column="ProcessDefinitionName" jdbcType="VARCHAR" />
<result property="processDefinitionKey" column="ProcessDefinitionKey" jdbcType="VARCHAR" />
<result property="processDefinitionVersion" column="ProcessDefinitionVersion" jdbcType="INTEGER" />
<result property="deploymentId" column="DeploymentId" jdbcType="VARCHAR" />
<result property="activityId" column="ACT_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="isMultiInstanceRoot" column="IS_MI_ROOT_" jdbcType="BOOLEAN" />
<result property="parentId" column="PARENT_ID_" jdbcType="VARCHAR" />
<result property="superExecutionId" column="SUPER_EXEC_" jdbcType="VARCHAR" />
<result property="rootProcessInstanceId" column="ROOT_PROC_INST_ID_" jdbcType="VARCHAR" />
<result property="suspensionState" column="SUSPENSION_STATE_" jdbcType="INTEGER"/>
<result property="tenantId" column="TENANT_ID_" jdbcType="VARCHAR" />
<result property="name" column="NAME_" jdbcType="VARCHAR" />
<result property="lockTime" column="LOCK_TIME_" jdbcType="TIMESTAMP" />
<result property="lockOwner" column="LOCK_OWNER_" jdbcType="VARCHAR" />
<result property="startActivityId" column="START_ACT_ID_" jdbcType="VARCHAR" />
<result property="startTime" column="START_TIME_" jdbcType="TIMESTAMP" />
<result property="startUserId" column="START_USER_ID_" jdbcType="VARCHAR" />
<result property="isCountEnabled" column="IS_COUNT_ENABLED_" jdbcType="BOOLEAN" />
<result property="eventSubscriptionCount" column="EVT_SUBSCR_COUNT_" jdbcType="INTEGER" />
<result property="taskCount" column="TASK_COUNT_" jdbcType="INTEGER" />
<result property="jobCount" column="JOB_COUNT_" jdbcType="INTEGER" />
<result property="timerJobCount" column="TIMER_JOB_COUNT_" jdbcType="INTEGER" />
<result property="suspendedJobCount" column="SUSP_JOB_COUNT_" jdbcType="INTEGER" />
<result property="deadLetterJobCount" column="DEADLETTER_JOB_COUNT_" jdbcType="INTEGER" />
<result property="externalWorkerJobCount" column="EXTERNAL_WORKER_JOB_COUNT_" jdbcType="INTEGER" />
<result property="variableCount" column="VAR_COUNT_" jdbcType="INTEGER" />
<result property="identityLinkCount" column="ID_LINK_COUNT_" jdbcType="INTEGER" />
<result property="callbackId" column="CALLBACK_ID_" jdbcType="VARCHAR" />
<result property="callbackType" column="CALLBACK_TYPE_" jdbcType="VARCHAR" />
<result property="referenceId" column="REFERENCE_ID_" jdbcType="VARCHAR" />
<result property="referenceType" column="REFERENCE_TYPE_" jdbcType="VARCHAR" />
<result property="propagatedStageInstanceId" column="PROPAGATED_STAGE_INST_ID_" jdbcType="VARCHAR" />
</resultMap>
<resultMap id="executionAndVariablesResultMap" type="org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl">
<id property="id" column="ID_" jdbcType="VARCHAR" />
<result property="revision" column="REV_" jdbcType="INTEGER" />
<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="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="isMultiInstanceRoot" column="IS_MI_ROOT_" jdbcType="BOOLEAN" />
<result property="parentId" column="PARENT_ID_" jdbcType="VARCHAR" />
<result property="superExecutionId" column="SUPER_EXEC_" jdbcType="VARCHAR" />
<result property="rootProcessInstanceId" column="ROOT_PROC_INST_ID_" jdbcType="VARCHAR" />
<result property="suspensionState" column="SUSPENSION_STATE_" jdbcType="INTEGER"/>
<result property="tenantId" column="TENANT_ID_" jdbcType="VARCHAR" />
<result property="name" column="NAME_" jdbcType="VARCHAR" />
<result property="startActivityId" column="START_ACT_ID_" jdbcType="VARCHAR" />
<result property="startTime" column="START_TIME_" jdbcType="TIMESTAMP" />
<result property="startUserId" column="START_USER_ID_" jdbcType="VARCHAR" />
<result property="isCountEnabled" column="IS_COUNT_ENABLED_" jdbcType="BOOLEAN" />
<result property="eventSubscriptionCount" column="EVT_SUBSCR_COUNT_" jdbcType="INTEGER" />
<result property="taskCount" column="TASK_COUNT_" jdbcType="INTEGER" />
<result property="jobCount" column="JOB_COUNT_" jdbcType="INTEGER" />
<result property="timerJobCount" column="TIMER_JOB_COUNT_" jdbcType="INTEGER" />
<result property="suspendedJobCount" column="SUSP_JOB_COUNT_" jdbcType="INTEGER" />
<result property="deadLetterJobCount" column="DEADLETTER_JOB_COUNT_" jdbcType="INTEGER" />
<result property="externalWorkerJobCount" column="EXTERNAL_WORKER_JOB_COUNT_" jdbcType="INTEGER" />
<result property="variableCount" column="VAR_COUNT_" jdbcType="INTEGER" />
<result property="identityLinkCount" column="ID_LINK_COUNT_" jdbcType="INTEGER" />
<result property="callbackId" column="CALLBACK_ID_" jdbcType="VARCHAR" />
<result property="callbackType" column="CALLBACK_TYPE_" jdbcType="VARCHAR" />
<result property="referenceId" column="REFERENCE_ID_" jdbcType="VARCHAR" />
<result property="referenceType" column="REFERENCE_TYPE_" jdbcType="VARCHAR" />
<result property="propagatedStageInstanceId" column="PROPAGATED_STAGE_INST_ID_" jdbcType="VARCHAR" />
<collection property="queryVariables" column="EXECUTION_ID_" javaType="ArrayList" ofType="org.flowable.variable.service.impl.persistence.entity.VariableInstanceEntityImpl">
<id property="id" column="VAR_ID_"/>
<result property="name" column="VAR_NAME_" javaType="String" jdbcType="VARCHAR" />
<result property="type" column="VAR_TYPE_" javaType="org.flowable.variable.api.types.VariableType" jdbcType="VARCHAR" />
<result property="revision" column="VAR_REV_" jdbcType="INTEGER" />
<result property="processInstanceId" column="VAR_PROC_INST_ID_" jdbcType="VARCHAR" />
<result property="executionId" column="VAR_EXECUTION_ID_" jdbcType="VARCHAR" />
<result property="taskId" column="VAR_TASK_ID_" jdbcType="VARCHAR" />
<result property="byteArrayRef" column="VAR_BYTEARRAY_ID_" typeHandler="VariableByteArrayRefTypeHandler"/>
<result property="doubleValue" column="VAR_DOUBLE_" jdbcType="DOUBLE" />
<result property="textValue" column="VAR_TEXT_" jdbcType="VARCHAR" />
<result property="textValue2" column="VAR_TEXT2_" jdbcType="VARCHAR" />
<result property="longValue" column="VAR_LONG_" jdbcType="BIGINT" />
</collection>
</resultMap>
<resultMap id="processInstanceAndVariablesResultMap" type="org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl">
<id property="id" column="ID_" jdbcType="VARCHAR" />
<result property="revision" column="REV_" jdbcType="INTEGER" />
<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="processDefinitionName" column="ProcessDefinitionName" jdbcType="VARCHAR" />
<result property="processDefinitionKey" column="ProcessDefinitionKey" jdbcType="VARCHAR" />
<result property="processDefinitionVersion" column="ProcessDefinitionVersion" jdbcType="INTEGER" />
<result property="deploymentId" column="DeploymentId" jdbcType="VARCHAR" />
<result property="activityId" column="ACT_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="isMultiInstanceRoot" column="IS_MI_ROOT_" jdbcType="BOOLEAN" />
<result property="parentId" column="PARENT_ID_" jdbcType="VARCHAR" />
<result property="superExecutionId" column="SUPER_EXEC_" jdbcType="VARCHAR" />
<result property="rootProcessInstanceId" column="ROOT_PROC_INST_ID_" jdbcType="VARCHAR" />
<result property="suspensionState" column="SUSPENSION_STATE_" jdbcType="INTEGER"/>
<result property="tenantId" column="TENANT_ID_" jdbcType="VARCHAR" />
<result property="name" column="NAME_" jdbcType="VARCHAR" />
<result property="lockTime" column="LOCK_TIME_" jdbcType="TIMESTAMP" />
<result property="lockOwner" column="LOCK_OWNER_" jdbcType="VARCHAR" />
<result property="startActivityId" column="START_ACT_ID_" jdbcType="VARCHAR" />
<result property="startTime" column="START_TIME_" jdbcType="TIMESTAMP" />
<result property="startUserId" column="START_USER_ID_" jdbcType="VARCHAR" />
<result property="isCountEnabled" column="IS_COUNT_ENABLED_" jdbcType="BOOLEAN" />
<result property="eventSubscriptionCount" column="EVT_SUBSCR_COUNT_" jdbcType="INTEGER" />
<result property="taskCount" column="TASK_COUNT_" jdbcType="INTEGER" />
<result property="jobCount" column="JOB_COUNT_" jdbcType="INTEGER" />
<result property="timerJobCount" column="TIMER_JOB_COUNT_" jdbcType="INTEGER" />
<result property="suspendedJobCount" column="SUSP_JOB_COUNT_" jdbcType="INTEGER" />
<result property="deadLetterJobCount" column="DEADLETTER_JOB_COUNT_" jdbcType="INTEGER" />
<result property="externalWorkerJobCount" column="EXTERNAL_WORKER_JOB_COUNT_" jdbcType="INTEGER" />
<result property="variableCount" column="VAR_COUNT_" jdbcType="INTEGER" />
<result property="identityLinkCount" column="ID_LINK_COUNT_" jdbcType="INTEGER" />
<result property="callbackId" column="CALLBACK_ID_" jdbcType="VARCHAR" />
<result property="callbackType" column="CALLBACK_TYPE_" jdbcType="VARCHAR" />
<result property="referenceId" column="REFERENCE_ID_" jdbcType="VARCHAR" />
<result property="referenceType" column="REFERENCE_TYPE_" jdbcType="VARCHAR" />
<result property="propagatedStageInstanceId" column="PROPAGATED_STAGE_INST_ID_" jdbcType="VARCHAR" />
<collection property="queryVariables" column="EXECUTION_ID_" javaType="ArrayList" ofType="org.flowable.variable.service.impl.persistence.entity.VariableInstanceEntityImpl">
<id property="id" column="VAR_ID_"/>
<result property="name" column="VAR_NAME_" javaType="String" jdbcType="VARCHAR" />
<result property="type" column="VAR_TYPE_" javaType="org.flowable.variable.api.types.VariableType" jdbcType="VARCHAR" />
<result property="revision" column="VAR_REV_" jdbcType="INTEGER" />
<result property="processInstanceId" column="VAR_PROC_INST_ID_" jdbcType="VARCHAR" />
<result property="executionId" column="VAR_EXECUTION_ID_" jdbcType="VARCHAR" />
<result property="taskId" column="VAR_TASK_ID_" jdbcType="VARCHAR" />
<result property="byteArrayRef" column="VAR_BYTEARRAY_ID_" typeHandler="VariableByteArrayRefTypeHandler"/>
<result property="doubleValue" column="VAR_DOUBLE_" jdbcType="DOUBLE" />
<result property="textValue" column="VAR_TEXT_" jdbcType="VARCHAR" />
<result property="textValue2" column="VAR_TEXT2_" jdbcType="VARCHAR" />
<result property="longValue" column="VAR_LONG_" jdbcType="BIGINT" />
</collection>
</resultMap>
<!-- EXECUTION SELECT -->
<select id="selectExecutionsWithSameRootProcessInstanceId" parameterType="org.flowable.common.engine.impl.db.ListQueryParameterObject" resultMap="executionResultMap">
select * from ${prefix}ACT_RU_EXECUTION
where ROOT_PROC_INST_ID_ = (select ROOT_PROC_INST_ID_ from ${prefix}ACT_RU_EXECUTION where ID_ = #{parameter})
</select>
<select id="selectExecution" parameterType="string" resultMap="executionResultMap">
select * from ${prefix}ACT_RU_EXECUTION where ID_ = #{id, jdbcType=VARCHAR}
</select>
<select id="selectExecutionsByParentExecutionId" parameterType="org.flowable.common.engine.impl.db.ListQueryParameterObject" resultMap="executionResultMap">
select * from ${prefix}ACT_RU_EXECUTION
where PARENT_ID_ = #{parameter}
</select>
<select id="countActiveExecutionsByParentId" parameterType="java.util.Map" resultType="long">
select count(ID_) from ${prefix}ACT_RU_EXECUTION
where PARENT_ID_ = #{parentId} and IS_ACTIVE_ = #{isActive}
</select>
<select id="selectExecutionsByRootProcessInstanceId" parameterType="org.flowable.common.engine.impl.db.ListQueryParameterObject" resultMap="executionResultMap">
select * from ${prefix}ACT_RU_EXECUTION
where ROOT_PROC_INST_ID_ = #{parameter}
</select>
<select id="selectChildExecutionsByProcessInstanceId" parameterType="org.flowable.common.engine.impl.db.ListQueryParameterObject" resultMap="executionResultMap">
select * from ${prefix}ACT_RU_EXECUTION
where PROC_INST_ID_ = #{parameter} and PARENT_ID_ is not null
</select>
<select id="selectExecutionsByProcessInstanceId" parameterType="org.flowable.common.engine.impl.db.ListQueryParameterObject" resultMap="executionResultMap">
select * from ${prefix}ACT_RU_EXECUTION
where PROC_INST_ID_ = #{parameter}
</select>
<select id="selectProcessInstanceIdsByProcessDefinitionId" parameterType="org.flowable.common.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="selectInactiveExecutionsForProcessInstance" parameterType="org.flowable.common.engine.impl.db.ListQueryParameterObject" resultMap="executionResultMap">
select *
from ${prefix}ACT_RU_EXECUTION
where PROC_INST_ID_ = #{parameter.processInstanceId}
and IS_ACTIVE_ = #{parameter.isActive}
</select>
<select id="selectInactiveExecutionsInActivityAndProcessInstance" parameterType="org.flowable.common.engine.impl.db.ListQueryParameterObject" resultMap="executionResultMap">
select *
from ${prefix}ACT_RU_EXECUTION
where ACT_ID_ = #{parameter.activityId}
and PROC_INST_ID_ = #{parameter.processInstanceId}
and IS_ACTIVE_ = #{parameter.isActive}
</select>
<select id="selectExecutionsByParentExecutionAndActivityIds" parameterType="org.flowable.common.engine.impl.db.ListQueryParameterObject" resultMap="executionResultMap">
select *
from ${prefix}ACT_RU_EXECUTION
where PARENT_ID_ = #{parameter.parentExecutionId}
and ACT_ID_ in
<foreach item="activityId" collection="parameter.activityIds" open="(" separator="," close=")">
#{activityId}
</foreach>
</select>
<select id="selectExecutionsByQueryCriteria" parameterType="org.flowable.engine.impl.ExecutionQueryImpl" resultMap="executionResultMap">
<if test="needsPaging">${limitBefore}</if>
SELECT RES.* <if test="needsPaging">${limitBetween}</if>, P.KEY_ as ProcessDefinitionKey, P.ID_ as ProcessDefinitionId, P.NAME_ as ProcessDefinitionName, P.VERSION_ as ProcessDefinitionVersion, P.DEPLOYMENT_ID_ as DeploymentId
<include refid="selectExecutionsByQueryCriteriaSql"/>
${orderBy}
<if test="needsPaging">${limitAfter}</if>
</select>
<select id="selectExecutionCountByQueryCriteria" parameterType="org.flowable.engine.impl.ExecutionQueryImpl" resultType="long">
select count(distinct RES.ID_)
<include refid="selectExecutionsByQueryCriteriaSql"/>
</select>
<!-- same as selectExecutionsByQueryCriteria, but with different parameterType -->
<select id="selectProcessInstanceByQueryCriteria" parameterType="org.flowable.engine.impl.ProcessInstanceQueryImpl" resultMap="processInstanceResultMap">
<if test="needsPaging">${limitBefore}</if>
SELECT RES.* <if test="needsPaging">${limitBetween}</if>, P.KEY_ as ProcessDefinitionKey, P.ID_ as ProcessDefinitionId, P.NAME_ as ProcessDefinitionName, P.VERSION_ as ProcessDefinitionVersion, P.DEPLOYMENT_ID_ as DeploymentId
<include refid="selectExecutionsByQueryCriteriaSql"/>
${orderBy}
<if test="needsPaging">${limitAfter}</if>
</select>
<select id="selectProcessInstanceCountByQueryCriteria" parameterType="org.flowable.engine.impl.ProcessInstanceQueryImpl" resultType="long">
select count(distinct RES.ID_)
<include refid="selectExecutionsByQueryCriteriaSql"/>
</select>
<sql id="selectExecutionsByQueryCriteriaSql">
from ${prefix}ACT_RU_EXECUTION RES
<!-- Doing an inner join on the definition table is OK, since it is a 1:1 relationship -->
inner join ${prefix}ACT_RE_PROCDEF P on RES.PROC_DEF_ID_ = P.ID_
<include refid="commonSelectExecutionsByQueryCriteriaSql"/>
</sql>
<select id="selectProcessInstanceWithVariablesByQueryCriteria" parameterType="org.flowable.engine.impl.ProcessInstanceQueryImpl" resultMap="processInstanceAndVariablesResultMap">
SELECT RES.*,
VAR.ID_ as VAR_ID_, VAR.NAME_ as VAR_NAME_, VAR.TYPE_ as VAR_TYPE_, VAR.REV_ as VAR_REV_,
VAR.PROC_INST_ID_ as VAR_PROC_INST_ID_, VAR.EXECUTION_ID_ as VAR_EXECUTION_ID_, VAR.TASK_ID_ as VAR_TASK_ID_,
VAR.BYTEARRAY_ID_ as VAR_BYTEARRAY_ID_, VAR.DOUBLE_ as VAR_DOUBLE_,
VAR.TEXT_ as VAR_TEXT_, VAR.TEXT2_ as VAR_TEXT2_, VAR.LONG_ as VAR_LONG_
FROM (
<!-- top 100 percent is only needed when doing order by in a subselect -->
<if test="needsPaging">${limitBefore}</if>
SELECT <if test="_databaseId == 'mssql'">top 100 percent</if> RES.* <if test="needsPaging">${limitBetween}</if>, P.KEY_ as ProcessDefinitionKey, P.ID_ as ProcessDefinitionId, P.NAME_ as ProcessDefinitionName, P.VERSION_ as ProcessDefinitionVersion, P.DEPLOYMENT_ID_ as DeploymentId
<include refid="selectProcessInstanceWithVariablesByQueryCriteriaSql"/>
${orderBy}
<if test="needsPaging">${limitAfter}</if>
) RES
left outer join ${prefix}ACT_RU_VARIABLE VAR ON RES.PROC_INST_ID_ = VAR.EXECUTION_ID_
<if test="needsProcessDefinitionOuterJoin">
inner join ${prefix}ACT_RE_PROCDEF P on RES.PROC_DEF_ID_ = P.ID_
</if>
${outerJoinOrderBy}
</select>
<sql id="selectProcessInstanceWithVariablesByQueryCriteriaSql">
from ${prefix}ACT_RU_EXECUTION RES
<!-- Doing an inner join on the definition table is OK, since it is a 1:1 relationship -->
inner join ${prefix}ACT_RE_PROCDEF P on RES.PROC_DEF_ID_ = P.ID_
<include refid="commonSelectExecutionsByQueryCriteriaSql"/>
</sql>
<sql id="commonSelectExecutionsByQueryCriteriaSql">
<where>
<if test="onlyProcessInstances">
RES.PARENT_ID_ is null
</if>
<if test="processDefinitionId != null">
and P.ID_ = #{processDefinitionId}
</if>
<if test="processDefinitionIds != null and !processDefinitionIds.isEmpty()">
and P.ID_ in
<foreach item="item" index="index" collection="processDefinitionIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="processDefinitionKey != null">
and P.KEY_ = #{processDefinitionKey}
</if>
<if test="processDefinitionKeys != null and !processDefinitionKeys.isEmpty()">
and P.KEY_ in
<foreach item="item" index="index" collection="processDefinitionKeys" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="processDefinitionCategory != null">
and P.CATEGORY_ = #{processDefinitionCategory}
</if>
<if test="processDefinitionName != null">
and P.NAME_ = #{processDefinitionName}
</if>
<if test="processDefinitionVersion != null">
and P.VERSION_ = #{processDefinitionVersion}
</if>
<if test="processDefinitionEngineVersion != null">
and P.ENGINE_VERSION_ = #{processDefinitionEngineVersion}
</if>
<if test="executionId != null">
and RES.ID_ = #{executionId}
</if>
<if test="processInstanceId != null">
and RES.PROC_INST_ID_ = #{processInstanceId}
</if>
<if test="rootProcessInstanceId != null">
and RES.ROOT_PROC_INST_ID_ = #{rootProcessInstanceId}
</if>
<if test="processInstanceIds != null and !processInstanceIds.isEmpty()">
and RES.PROC_INST_ID_ in
<foreach item="item" index="index" collection="processInstanceIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="businessKey != null or businessKeyLike != null">
<choose>
<when test="includeChildExecutionsWithBusinessKeyQuery">
and exists (
select 1
from ${prefix}ACT_RU_EXECUTION INST
<where>
RES.PROC_INST_ID_ = INST.ID_
<if test="businessKey != null">
and INST.BUSINESS_KEY_ = #{businessKey}
</if>
<if test="businessKeyLike != null">
and INST.BUSINESS_KEY_ like #{businessKeyLike}${wildcardEscapeClause}
</if>
</where>
)
</when>
<otherwise>
<if test="businessKey != null">
and RES.BUSINESS_KEY_ = #{businessKey}
</if>
<if test="businessKeyLike != null">
and RES.BUSINESS_KEY_ like #{businessKeyLike}${wildcardEscapeClause}
</if>
</otherwise>
</choose>
</if>
<if test="activityId != null">
and RES.ACT_ID_ = #{activityId} and RES.IS_ACTIVE_ = #{isActive}
</if>
<if test="parentId != null">
and RES.PARENT_ID_ = #{parentId}
</if>
<if test="onlyChildExecutions">
and RES.PARENT_ID_ is not null
</if>
<if test="onlySubProcessExecutions">
and ((RES.PARENT_ID_ is not null or RES.SUPER_EXEC_ is not null) and RES.IS_SCOPE_ = #{onlySubProcessExecutions,typeHandler=org.apache.ibatis.type.BooleanTypeHandler})
</if>
<if test="onlyProcessInstanceExecutions">
and RES.PARENT_ID_ is null
</if>
<if test="deploymentId != null">
and P.DEPLOYMENT_ID_ = #{deploymentId}
</if>
<if test="deploymentIds != null && deploymentIds.size() > 0">
and P.DEPLOYMENT_ID_ IN
<foreach item="deployment" index="index" collection="deploymentIds"
open="(" separator="," close=")">
#{deployment}
</foreach>
</if>
<if test="superProcessInstanceId != null">
<!-- A sub process instance is stored under a certain *execution*, potentially nested.
A sub process instance is NOT stored under the process instanc, hence the following: -->
and RES.SUPER_EXEC_ IN (select ID_ from ${prefix}ACT_RU_EXECUTION where PROC_INST_ID_ = #{superProcessInstanceId})
</if>
<if test="subProcessInstanceId != null">
and RES.ID_ = (select PROC_INST_ID_ from ${prefix}ACT_RU_EXECUTION where ID_ = (select SUPER_EXEC_ from ${prefix}ACT_RU_EXECUTION where ID_ = #{subProcessInstanceId}))
</if>
<if test="excludeSubprocesses">
and RES.SUPER_EXEC_ is null
</if>
<if test="suspensionState != null">
<if test="suspensionState.stateCode == 1">
and (RES.SUSPENSION_STATE_ = 1)
</if>
<if test="suspensionState.stateCode == 2">
and (RES.SUSPENSION_STATE_ = 2)
</if>
</if>
<if test="callbackId != null">
and CALLBACK_ID_ = #{callbackId}
</if>
<if test="callbackType != null">
and CALLBACK_TYPE_ = #{callbackType}
</if>
<if test="referenceId != null">
and REFERENCE_ID_ = #{referenceId}
</if>
<if test="referenceType != null">
and REFERENCE_TYPE_ = #{referenceType}
</if>
<if test="tenantId != null">
and RES.TENANT_ID_ = #{tenantId}
</if>
<if test="tenantIdLike != null">
and RES.TENANT_ID_ like #{tenantIdLike}${wildcardEscapeClause}
</if>
<if test="withoutTenantId">
and (RES.TENANT_ID_ = '' or RES.TENANT_ID_ is null)
</if>
<if test="name != null">
and RES.NAME_ = #{name}
</if>
<if test="nameLike != null">
and RES.NAME_ like #{nameLike}${wildcardEscapeClause}
</if>
<if test="nameLikeIgnoreCase != null">
and lower(RES.NAME_) like #{nameLikeIgnoreCase}${wildcardEscapeClause}
</if>
<if test="activeActivityId != null">
and EXISTS(select ID_ from ${prefix}ACT_RU_ACTINST A where A.PROC_INST_ID_ = RES.ID_ and A.ACT_ID_ = #{activeActivityId} and A.END_TIME_ is null)
</if>
<if test="activeActivityIds != null">
and EXISTS(select ID_ from ${prefix}ACT_RU_ACTINST A where A.PROC_INST_ID_ = RES.ID_ and A.ACT_ID_ in
<foreach item="activeActivityId" index="index" collection="activeActivityIds" open="(" separator="," close=")">
#{activeActivityId}
</foreach>
and A.END_TIME_ is null)
</if>
<if test="involvedUser != null">
and EXISTS(select ID_ from ${prefix}ACT_RU_IDENTITYLINK I where I.PROC_INST_ID_ = RES.ID_ and I.USER_ID_ = #{involvedUser})
</if>
<if test="involvedUserIdentityLink != null">
and EXISTS(select ID_ from ${prefix}ACT_RU_IDENTITYLINK I where I.PROC_INST_ID_ = RES.ID_ and
I.USER_ID_ = #{involvedUserIdentityLink.userId} and I.TYPE_ = #{involvedUserIdentityLink.type})
</if>
<if test="involvedGroups != null">
and EXISTS(
select ID_ from ${prefix}ACT_RU_IDENTITYLINK I where I.PROC_INST_ID_ = RES.ID_ and
(
<foreach item="involvedGroupListItem" index="groupIndex" collection="safeInvolvedGroups">
<if test="groupIndex > 0">
or
</if>
I.GROUP_ID_ IN
<foreach item="group" index="index" collection="involvedGroupListItem"
open="(" separator="," close=")">
#{group}
</foreach>
</foreach>
)
)
</if>
<if test="involvedGroupIdentityLink != null">
and EXISTS(select ID_ from ${prefix}ACT_RU_IDENTITYLINK I where I.PROC_INST_ID_ = RES.ID_ and
I.GROUP_ID_ = #{involvedGroupIdentityLink.groupId} and I.TYPE_ = #{involvedGroupIdentityLink.type})
</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">
<choose>
<when test="queryVariableValue.operator.equals('EXISTS')">
and EXISTS (
select ID_ from ${prefix}ACT_RU_VARIABLE where NAME_ = #{queryVariableValue.name}
<if test="!queryVariableValue.local">
and RES.PROC_INST_ID_ = EXECUTION_ID_
</if>
<if test="queryVariableValue.local">
and RES.ID_ = EXECUTION_ID_
</if>
)
</when>
<when test="queryVariableValue.operator.equals('NOT_EXISTS')">
and NOT EXISTS (
select ID_ from ${prefix}ACT_RU_VARIABLE where NAME_ = #{queryVariableValue.name}
<if test="!queryVariableValue.local">
and RES.PROC_INST_ID_ = EXECUTION_ID_
</if>
<if test="queryVariableValue.local">
and RES.ID_ = EXECUTION_ID_
</if>
)
</when>
<otherwise>
and exists (
select 1
from ${prefix}ACT_RU_VARIABLE V
<where>
<if test="!queryVariableValue.local">
and RES.PROC_INST_ID_ = V.EXECUTION_ID_
</if>
<if test="queryVariableValue.local">
and RES.ID_ = V.EXECUTION_ID_
</if>
<if test="queryVariableValue.name != null">
<!-- Match-all variable-names when name is null -->
and V.NAME_= #{queryVariableValue.name}
</if>
<if test="queryVariableValue.needsTypeCheck()">
and V.TYPE_ = #{queryVariableValue.type}
</if>
<if test="queryVariableValue.textValue != null && queryVariableValue.longValue == null && queryVariableValue.doubleValue == null">
<choose>
<when test="queryVariableValue.operator.equals('EQUALS_IGNORE_CASE') || queryVariableValue.operator.equals('NOT_EQUALS_IGNORE_CASE') || queryVariableValue.operator.equals('LIKE_IGNORE_CASE')">
and (lower(V.TEXT_)
</when>
<otherwise>
and (V.TEXT_
</otherwise>
</choose>
<choose>
<when test="queryVariableValue.operator.equals('LIKE') || queryVariableValue.operator.equals('LIKE_IGNORE_CASE')">LIKE</when>
<otherwise><include refid="executionVariableOperator" /></otherwise>
</choose>
#{queryVariableValue.textValue}
<choose>
<when test="queryVariableValue.operator.equals('LIKE') || queryVariableValue.operator.equals('LIKE_IGNORE_CASE')">${wildcardEscapeClause}</when>
</choose>
<if test="queryVariableValue.operator.equals('NOT_EQUALS') || queryVariableValue.operator.equals('NOT_EQUALS_IGNORE_CASE')">
or V.TEXT_ is null
</if>
)
</if>
<if test="queryVariableValue.textValue2 != null">
and V.TEXT2_
<choose>
<when test="queryVariableValue.operator.equals('LIKE')">LIKE</when>
<otherwise><include refid="executionVariableOperator" /></otherwise>
</choose>
#{queryVariableValue.textValue2}
<choose>
<when test="queryVariableValue.operator.equals('LIKE')">${wildcardEscapeClause}</when>
</choose>
</if>
<if test="queryVariableValue.longValue != null">
and (V.LONG_
<include refid="executionVariableOperator" />
#{queryVariableValue.longValue}
<if test="queryVariableValue.operator.equals('NOT_EQUALS') || queryVariableValue.operator.equals('NOT_EQUALS_IGNORE_CASE')">
or V.LONG_ is null
</if>
)
</if>
<if test="queryVariableValue.doubleValue != null">
and (V.DOUBLE_
<include refid="executionVariableOperator" />
#{queryVariableValue.doubleValue}
<if test="queryVariableValue.operator.equals('NOT_EQUALS') || queryVariableValue.operator.equals('NOT_EQUALS_IGNORE_CASE')">
or V.DOUBLE_ is null
</if>
)
</if>
<!-- Null variable type -->
<if test="queryVariableValue.textValue == null && queryVariableValue.textValue2 == null && queryVariableValue.longValue == null && queryVariableValue.doubleValue == null">
<choose>
<when test="queryVariableValue.operator.equals('NOT_EQUALS')">
and (V.TEXT_ is not null or V.TEXT2_ is not null or V.LONG_ is not null or V.DOUBLE_ is not null or V.BYTEARRAY_ID_ is not null)
</when>
<otherwise>
and V.TEXT_ is null and V.TEXT2_ is null and V.LONG_ is null and V.DOUBLE_ is null and V.BYTEARRAY_ID_ is null
</otherwise>
</choose>
</if>
</where>
)
</otherwise>
</choose>
</foreach>
<!-- event subscriptions -->
<if test="eventSubscriptions != null">
<foreach collection="eventSubscriptions" index="index" item="eventSubscriptionValue">
and exists (
select 1
from ${prefix}ACT_RU_EVENT_SUBSCR EVT
<where>
RES.ID_ = EVT.EXECUTION_ID_
and EVT.EVENT_TYPE_ = #{eventSubscriptionValue.eventType}
and EVT.EVENT_NAME_ = #{eventSubscriptionValue.eventName}
</where>
)
</foreach>
</if>
<foreach item="orQueryObject" index="orIndex" collection="orQueryObjects">
and
<trim prefix="(" prefixOverrides="OR" suffix=")">
<if test="orQueryObject.processDefinitionId != null">
P.ID_ = #{orQueryObject.processDefinitionId}
</if>
<if test="orQueryObject.processDefinitionIds != null and !orQueryObject.processDefinitionIds.isEmpty()">
or P.ID_ in
<foreach item="item" index="index" collection="orQueryObject.processDefinitionIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="orQueryObject.processDefinitionKey != null">
or P.KEY_ = #{orQueryObject.processDefinitionKey}
</if>
<if test="orQueryObject.processDefinitionKeys != null and !orQueryObject.processDefinitionKeys.isEmpty()">
or P.KEY_ in
<foreach item="item" index="index" collection="orQueryObject.processDefinitionKeys" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="orQueryObject.processDefinitionCategory != null">
or P.CATEGORY_ = #{orQueryObject.processDefinitionCategory}
</if>
<if test="orQueryObject.processDefinitionName != null">
or P.NAME_ = #{orQueryObject.processDefinitionName}
</if>
<if test="orQueryObject.processDefinitionVersion != null">
or P.VERSION_ = #{orQueryObject.processDefinitionVersion}
</if>
<if test="orQueryObject.processDefinitionEngineVersion != null">
or P.ENGINE_VERSION_ = #{orQueryObject.processDefinitionEngineVersion}
</if>
<if test="orQueryObject.executionId != null">
or RES.ID_ = #{orQueryObject.executionId}
</if>
<if test="orQueryObject.processInstanceId != null">
or RES.PROC_INST_ID_ = #{orQueryObject.processInstanceId}
</if>
<if test="orQueryObject.processInstanceIds != null and !orQueryObject.processInstanceIds.isEmpty()">
or RES.PROC_INST_ID_ in
<foreach item="item" index="index" collection="orQueryObject.processInstanceIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="orQueryObject.businessKey != null">
or RES.BUSINESS_KEY_ = #{orQueryObject.businessKey}
</if>
<if test="orQueryObject.activityId != null">
or (RES.ACT_ID_ = #{orQueryObject.activityId} and RES.IS_ACTIVE_ = #{isActive})
</if>
<if test="orQueryObject.parentId != null">
or RES.PARENT_ID_ = #{orQueryObject.parentId}
</if>
<if test="orQueryObject.deploymentId != null">
or P.DEPLOYMENT_ID_ = #{orQueryObject.deploymentId}
</if>
<if test="orQueryObject.deploymentIds != null && orQueryObject.deploymentIds.size() > 0">
or P.DEPLOYMENT_ID_ IN
<foreach item="deployment" index="index" collection="orQueryObject.deploymentIds"
open="(" separator="," close=")">
#{deployment}
</foreach>
</if>
<if test="orQueryObject.superProcessInstanceId != null">
<!-- A sub process instance is stored under a certain *execution*, potentially nested.
A sub process instance is NOT stored under the process instanc, hence the following: -->
or RES.SUPER_EXEC_ IN (select ID_ from ${prefix}ACT_RU_EXECUTION where PROC_INST_ID_ = #{orQueryObject.superProcessInstanceId})
</if>
<if test="orQueryObject.subProcessInstanceId != null">
or RES.ID_ = (select PROC_INST_ID_ from ${prefix}ACT_RU_EXECUTION where ID_ = (select SUPER_EXEC_ from ${prefix}ACT_RU_EXECUTION where ID_ = #{orQueryObject.subProcessInstanceId}))
</if>
<if test="orQueryObject.excludeSubprocesses">
or RES.SUPER_EXEC_ is null
</if>
<if test="orQueryObject.suspensionState != null">
<if test="orQueryObject.suspensionState.stateCode == 1">
or (RES.SUSPENSION_STATE_ = 1)
</if>
<if test="orQueryObject.suspensionState.stateCode == 2">
or (RES.SUSPENSION_STATE_ = 2)
</if>
</if>
<if test="orQueryObject.callbackId != null">
or CALLBACK_ID_ = #{orQueryObject.callbackId}
</if>
<if test="orQueryObject.callbackType != null">
or CALLBACK_TYPE_ = #{orQueryObject.callbackType}
</if>
<if test="orQueryObject.referenceId != null">
or REFERENCE_ID_ = #{orQueryObject.referenceId}
</if>
<if test="orQueryObject.referenceType != null">
or REFERENCE_TYPE_ = #{orQueryObject.referenceType}
</if>
<if test="orQueryObject.tenantId != null">
or RES.TENANT_ID_ = #{orQueryObject.tenantId}
</if>
<if test="orQueryObject.tenantIdLike != null">
or RES.TENANT_ID_ like #{orQueryObject.tenantIdLike}${wildcardEscapeClause}
</if>
<if test="orQueryObject.withoutTenantId">
or (RES.TENANT_ID_ = '' or RES.TENANT_ID_ is null)
</if>
<if test="orQueryObject.name != null">
or RES.NAME_ = #{orQueryObject.name}
</if>
<if test="orQueryObject.nameLike != null">
or RES.NAME_ like #{orQueryObject.nameLike}${wildcardEscapeClause}
</if>
<if test="orQueryObject.nameLikeIgnoreCase != null">
or lower(RES.NAME_) like #{orQueryObject.nameLikeIgnoreCase}${wildcardEscapeClause}
</if>
<if test="orQueryObject.activeActivityId != null">
or EXISTS(select ID_ from ${prefix}ACT_RU_ACTINST A where A.PROC_INST_ID_ = RES.ID_ and A.ACT_ID_ = #{orQueryObject.activeActivityId} and A.END_TIME_ is null)
</if>
<if test="orQueryObject.activeActivityIds != null">
or EXISTS(select ID_ from ${prefix}ACT_RU_ACTINST A where A.PROC_INST_ID_ = RES.ID_ and A.ACT_ID_ in
<foreach item="activeActivityId" index="index" collection="orQueryObject.activeActivityIds" open="(" separator="," close=")">
#{activeActivityId}
</foreach>
and A.END_TIME_ is null)
</if>
<if test="orQueryObject.involvedUser != null">
or EXISTS(select ID_ from ${prefix}ACT_RU_IDENTITYLINK I where I.PROC_INST_ID_ = RES.ID_ and I.USER_ID_ = #{orQueryObject.involvedUser})
</if>
<if test="orQueryObject.involvedUserIdentityLink != null">
or EXISTS(select ID_ from ${prefix}ACT_RU_IDENTITYLINK I where I.PROC_INST_ID_ = RES.ID_ and
I.USER_ID_ = #{orQueryObject.involvedUserIdentityLink.userId} and I.TYPE_ = #{orQueryObject.involvedUserIdentityLink.type})
</if>
<if test="orQueryObject.involvedGroups != null">
or EXISTS(select ID_ from ${prefix}ACT_RU_IDENTITYLINK I where I.PROC_INST_ID_ = RES.ID_ and
(
<foreach item="involvedGroupListItem" index="groupIndex" collection="orQueryObject.safeInvolvedGroups">
<if test="groupIndex > 0">
or
</if>
I.GROUP_ID_ IN
<foreach item="group" index="index" collection="involvedGroupListItem"
open="(" separator="," close=")">
#{group}
</foreach>
</foreach>
)
)
</if>
<if test="orQueryObject.involvedGroupIdentityLink != null">
or EXISTS(select ID_ from ${prefix}ACT_RU_IDENTITYLINK I where I.PROC_INST_ID_ = RES.ID_ and
I.GROUP_ID_ = #{orQueryObject.involvedGroupIdentityLink.groupId} and I.TYPE_ = #{orQueryObject.involvedGroupIdentityLink.type})
</if>
<!-- PLEASE NOTE: If you change anything have a look into the HistoricVariableInstance & HistoricProcessInstance, the same query object is used there! -->
<foreach collection="orQueryObject.queryVariableValues" index="index" item="queryVariableValue">
or
<trim prefix="(" prefixOverrides="AND" suffix=")">
<choose>
<when test="queryVariableValue.operator.equals('EXISTS')">
and EXISTS (
select ID_ from ${prefix}ACT_RU_VARIABLE where NAME_ = #{queryVariableValue.name}
<if test="!queryVariableValue.local">
and RES.PROC_INST_ID_ = EXECUTION_ID_
</if>
<if test="queryVariableValue.local">
and RES.ID_ = EXECUTION_ID_
</if>
)
</when>
<when test="queryVariableValue.operator.equals('NOT_EXISTS')">
and NOT EXISTS (
select ID_ from ${prefix}ACT_RU_VARIABLE where NAME_ = #{queryVariableValue.name}
<if test="!queryVariableValue.local">
and RES.PROC_INST_ID_ = EXECUTION_ID_
</if>
<if test="queryVariableValue.local">
and RES.ID_ = EXECUTION_ID_
</if>
)
</when>
<otherwise>
and exists (
select 1
from ${prefix}ACT_RU_VARIABLE V
<where>
<if test="!queryVariableValue.local">
and RES.PROC_INST_ID_ = V.EXECUTION_ID_
</if>
<if test="queryVariableValue.local">
and RES.ID_ = V.EXECUTION_ID_
</if>
<if test="queryVariableValue.name != null">
<!-- Match-all variable-names when name is null -->
and V.NAME_= #{queryVariableValue.name}
</if>
<if test="queryVariableValue.needsTypeCheck()">
and V.TYPE_ = #{queryVariableValue.type}
</if>
<if test="queryVariableValue.textValue != null && queryVariableValue.longValue == null && queryVariableValue.doubleValue == null">
<choose>
<when test="queryVariableValue.operator.equals('EQUALS_IGNORE_CASE') || queryVariableValue.operator.equals('NOT_EQUALS_IGNORE_CASE') || queryVariableValue.operator.equals('LIKE_IGNORE_CASE')">
and (lower(V.TEXT_)
</when>
<otherwise>
and (V.TEXT_
</otherwise>
</choose>
<choose>
<when test="queryVariableValue.operator.equals('LIKE') || queryVariableValue.operator.equals('LIKE_IGNORE_CASE')">LIKE</when>
<otherwise><include refid="executionVariableOperator" /></otherwise>
</choose>
#{queryVariableValue.textValue}
<choose>
<when test="queryVariableValue.operator.equals('LIKE') || queryVariableValue.operator.equals('LIKE_IGNORE_CASE')">${wildcardEscapeClause}</when>
</choose>
<if test="queryVariableValue.operator.equals('NOT_EQUALS') || queryVariableValue.operator.equals('NOT_EQUALS_IGNORE_CASE')">
or V.TEXT_ is null
</if>
)
</if>
<if test="queryVariableValue.textValue2 != null">
and V.TEXT2_
<choose>
<when test="queryVariableValue.operator.equals('LIKE')">LIKE</when>
<otherwise><include refid="executionVariableOperator" /></otherwise>
</choose>
#{queryVariableValue.textValue2}
<choose>
<when test="queryVariableValue.operator.equals('LIKE')">${wildcardEscapeClause}</when>
</choose>
</if>
<if test="queryVariableValue.longValue != null">
and (V.LONG_
<include refid="executionVariableOperator" />
#{queryVariableValue.longValue}
<if test="queryVariableValue.operator.equals('NOT_EQUALS') || queryVariableValue.operator.equals('NOT_EQUALS_IGNORE_CASE')">
or V.LONG_ is null
</if>
)
</if>
<if test="queryVariableValue.doubleValue != null">
and (V.DOUBLE_
<include refid="executionVariableOperator" />
#{queryVariableValue.doubleValue}
<if test="queryVariableValue.operator.equals('NOT_EQUALS') || queryVariableValue.operator.equals('NOT_EQUALS_IGNORE_CASE')">
or V.DOUBLE_ is null
</if>
)
</if>
<!-- Null variable type -->
<if test="queryVariableValue.textValue == null && queryVariableValue.textValue2 == null && queryVariableValue.longValue == null && queryVariableValue.doubleValue == null">
<choose>
<when test="queryVariableValue.operator.equals('NOT_EQUALS')">
and (V.TEXT_ is not null or V.TEXT2_ is not null or V.LONG_ is not null or V.DOUBLE_ is not null or V.BYTEARRAY_ID_ is not null)
</when>
<otherwise>
and V.TEXT_ is null and V.TEXT2_ is null and V.LONG_ is null and V.DOUBLE_ is null and V.BYTEARRAY_ID_ is null
</otherwise>
</choose>
</if>
</where>
)
</otherwise>
</choose>
</trim>
</foreach>
</trim>
</foreach>
<if test="onlyProcessInstances && withJobException">
and exists (
select 1
from ${prefix}ACT_RU_TIMER_JOB JOB
<where>
RES.PROC_INST_ID_ = JOB.PROCESS_INSTANCE_ID_
and (JOB.EXCEPTION_MSG_ is not null or JOB.EXCEPTION_STACK_ID_ is not null)
</where>
)
</if>
<if test="startedBefore != null">
and RES.START_TIME_ <= #{startedBefore}
</if>
<if test="startedAfter != null">
and RES.START_TIME_ >= #{startedAfter}
</if>
<if test="startedBy != null">
and RES.START_USER_ID_ = #{startedBy}
</if>
</where>
</sql>
<sql id="executionVariableOperator">
<choose>
<when test="queryVariableValue.operator.equals('EQUALS')">=</when>
<when test="queryVariableValue.operator.equals('EQUALS_IGNORE_CASE')">=</when>
<when test="queryVariableValue.operator.equals('NOT_EQUALS')"><></when>
<when test="queryVariableValue.operator.equals('NOT_EQUALS_IGNORE_CASE')"><></when>
<when test="queryVariableValue.operator.equals('GREATER_THAN')">></when>
<when test="queryVariableValue.operator.equals('GREATER_THAN_OR_EQUAL')">>=</when>
<when test="queryVariableValue.operator.equals('LESS_THAN')"><</when>
<when test="queryVariableValue.operator.equals('LESS_THAN_OR_EQUAL')"><=</when>
</choose>
</sql>
<select id="selectSubProcessInstanceBySuperExecutionId" parameterType="string" resultMap="executionResultMap">
select *
from ${prefix}ACT_RU_EXECUTION
where SUPER_EXEC_ = #{parameter}
</select>
<select id="selectExecutionByNativeQuery" parameterType="java.util.Map" resultMap="executionResultMap">
<include refid="org.flowable.common.engine.db.selectByNativeQuery"/>
</select>
<select id="selectExecutionCountByNativeQuery" parameterType="java.util.Map" resultType="long">
${sql}
</select>
</mapper>