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.HistoricProcessInstance.xml Maven / Gradle / Ivy
<?xml version="1.0" encoding="UTF-8" ?>
<!--
~ Licensed under the Apache License, Version 2.0 (the "License");
~ 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.flowable.engine.impl.persistence.entity.HistoricProcessInstanceEntityImpl">
<!-- HISTORIC PROCESS INSTANCE INSERT -->
<insert id="insertHistoricProcessInstance" parameterType="org.flowable.engine.impl.persistence.entity.HistoricProcessInstanceEntityImpl">
insert into ${prefix}ACT_HI_PROCINST (
ID_,
REV_,
PROC_INST_ID_,
BUSINESS_KEY_,
PROC_DEF_ID_,
START_TIME_,
END_TIME_,
DURATION_,
START_USER_ID_,
START_ACT_ID_,
END_ACT_ID_,
SUPER_PROCESS_INSTANCE_ID_,
DELETE_REASON_,
TENANT_ID_,
NAME_,
CALLBACK_ID_,
CALLBACK_TYPE_,
REFERENCE_ID_,
REFERENCE_TYPE_
) values (
#{id ,jdbcType=VARCHAR},
1, #{processInstanceId, jdbcType=VARCHAR},
#{businessKey, jdbcType=VARCHAR},
#{processDefinitionId, jdbcType=VARCHAR},
#{startTime, jdbcType=TIMESTAMP},
#{endTime, jdbcType=TIMESTAMP},
#{durationInMillis ,jdbcType=BIGINT},
#{startUserId, jdbcType=VARCHAR},
#{startActivityId, jdbcType=VARCHAR},
#{endActivityId, jdbcType=VARCHAR},
#{superProcessInstanceId, jdbcType=VARCHAR},
#{deleteReason, jdbcType=VARCHAR},
#{tenantId, jdbcType=VARCHAR},
#{name, jdbcType=VARCHAR},
#{callbackId, jdbcType=VARCHAR},
#{callbackType, jdbcType=VARCHAR},
#{referenceId, jdbcType=VARCHAR},
#{referenceType, jdbcType=VARCHAR}
)
</insert>
<insert id="bulkInsertHistoricProcessInstance" parameterType="java.util.List">
insert into ${prefix}ACT_HI_PROCINST (
ID_,
REV_,
PROC_INST_ID_,
BUSINESS_KEY_,
PROC_DEF_ID_,
START_TIME_,
END_TIME_,
DURATION_,
START_USER_ID_,
START_ACT_ID_,
END_ACT_ID_,
SUPER_PROCESS_INSTANCE_ID_,
DELETE_REASON_,
TENANT_ID_,
NAME_,
CALLBACK_ID_,
CALLBACK_TYPE_,
REFERENCE_ID_,
REFERENCE_TYPE_
) values
<foreach collection="list" item="historicProcessInstance" index="index" separator=",">
(
#{historicProcessInstance.id ,jdbcType=VARCHAR},
1, #{historicProcessInstance.processInstanceId, jdbcType=VARCHAR},
#{historicProcessInstance.businessKey, jdbcType=VARCHAR},
#{historicProcessInstance.processDefinitionId, jdbcType=VARCHAR},
#{historicProcessInstance.startTime, jdbcType=TIMESTAMP},
#{historicProcessInstance.endTime, jdbcType=TIMESTAMP},
#{historicProcessInstance.durationInMillis ,jdbcType=BIGINT},
#{historicProcessInstance.startUserId, jdbcType=VARCHAR},
#{historicProcessInstance.startActivityId, jdbcType=VARCHAR},
#{historicProcessInstance.endActivityId, jdbcType=VARCHAR},
#{historicProcessInstance.superProcessInstanceId, jdbcType=VARCHAR},
#{historicProcessInstance.deleteReason, jdbcType=VARCHAR},
#{historicProcessInstance.tenantId, jdbcType=VARCHAR},
#{historicProcessInstance.name, jdbcType=VARCHAR},
#{historicProcessInstance.callbackId, jdbcType=VARCHAR},
#{historicProcessInstance.callbackType, jdbcType=VARCHAR},
#{historicProcessInstance.referenceId, jdbcType=VARCHAR},
#{historicProcessInstance.referenceType, jdbcType=VARCHAR}
)
</foreach>
</insert>
<insert id="bulkInsertHistoricProcessInstance" databaseId="oracle" parameterType="java.util.List">
INSERT ALL
<foreach collection="list" item="historicProcessInstance" index="index">
INTO ${prefix}ACT_HI_PROCINST (
ID_,
REV_,
PROC_INST_ID_,
BUSINESS_KEY_,
PROC_DEF_ID_,
START_TIME_,
END_TIME_,
DURATION_,
START_USER_ID_,
START_ACT_ID_,
END_ACT_ID_,
SUPER_PROCESS_INSTANCE_ID_,
DELETE_REASON_,
TENANT_ID_,
NAME_,
CALLBACK_ID_,
CALLBACK_TYPE_,
REFERENCE_ID_,
REFERENCE_TYPE_
) VALUES
(
#{historicProcessInstance.id ,jdbcType=VARCHAR},
1, #{historicProcessInstance.processInstanceId, jdbcType=VARCHAR},
#{historicProcessInstance.businessKey, jdbcType=VARCHAR},
#{historicProcessInstance.processDefinitionId, jdbcType=VARCHAR},
#{historicProcessInstance.startTime, jdbcType=TIMESTAMP},
#{historicProcessInstance.endTime, jdbcType=TIMESTAMP},
#{historicProcessInstance.durationInMillis ,jdbcType=BIGINT},
#{historicProcessInstance.startUserId, jdbcType=VARCHAR},
#{historicProcessInstance.startActivityId, jdbcType=VARCHAR},
#{historicProcessInstance.endActivityId, jdbcType=VARCHAR},
#{historicProcessInstance.superProcessInstanceId, jdbcType=VARCHAR},
#{historicProcessInstance.deleteReason, jdbcType=VARCHAR},
#{historicProcessInstance.tenantId, jdbcType=VARCHAR},
#{historicProcessInstance.name, jdbcType=VARCHAR},
#{historicProcessInstance.callbackId, jdbcType=VARCHAR},
#{historicProcessInstance.callbackType, jdbcType=VARCHAR},
#{historicProcessInstance.referenceId, jdbcType=VARCHAR},
#{historicProcessInstance.referenceType, jdbcType=VARCHAR}
)
</foreach>
SELECT * FROM dual
</insert>
<!-- HISTORIC PROCESS INSTANCE UPDATE -->
<update id="updateHistoricProcessInstance" parameterType="org.flowable.engine.impl.persistence.entity.HistoricProcessInstanceEntityImpl">
update ${prefix}ACT_HI_PROCINST
<set>
REV_ = #{revisionNext, jdbcType=INTEGER},
<if test="originalPersistentState.processDefinitionId != processDefinitionId">
PROC_DEF_ID_ = #{processDefinitionId, jdbcType=VARCHAR},
</if>
<if test="originalPersistentState.businessKey != businessKey">
BUSINESS_KEY_ = #{businessKey, jdbcType=VARCHAR},
</if>
<if test="originalPersistentState.startTime != startTime">
START_TIME_ = #{startTime, jdbcType=TIMESTAMP},
</if>
<if test="originalPersistentState.endTime != endTime">
END_TIME_ = #{endTime, jdbcType=TIMESTAMP},
</if>
<if test="originalPersistentState.durationInMillis != durationInMillis">
DURATION_ = #{durationInMillis ,jdbcType=BIGINT},
</if>
<if test="originalPersistentState.endActivityId != endActivityId">
END_ACT_ID_ = #{endActivityId, jdbcType=VARCHAR},
</if>
<if test="originalPersistentState.deleteReason != deleteReason">
DELETE_REASON_ = #{deleteReason, jdbcType=VARCHAR},
</if>
<if test="originalPersistentState.name != name">
NAME_ = #{name, jdbcType=VARCHAR},
</if>
<if test="originalPersistentState.callbackId != callbackId">
CALLBACK_ID_ = #{callbackId, jdbcType=VARCHAR},
</if>
<if test="originalPersistentState.callbackType != callbackType">
CALLBACK_TYPE_ = #{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>
</set>
where ID_ = #{id}
and REV_ = #{revision, jdbcType=INTEGER}
</update>
<!-- HISTORIC PROCESS INSTANCE DELETE -->
<delete id="deleteHistoricProcessInstance">
delete from ${prefix}ACT_HI_PROCINST where PROC_INST_ID_ = #{processInstanceId}
</delete>
<delete id="bulkDeleteHistoricProcessInstance" parameterType="java.util.Collection">
delete from ${prefix}ACT_HI_PROCINST where
<foreach item="procInst" collection="list" index="index" separator=" or ">
ID_ = #{procInst.id, jdbcType=VARCHAR}
</foreach>
</delete>
<!-- HISTORIC PROCESS INSTANCE RESULT MAP -->
<resultMap id="historicProcessInstanceResultMap" type="org.flowable.engine.impl.persistence.entity.HistoricProcessInstanceEntityImpl">
<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="PROC_DEF_NAME_" jdbcType="VARCHAR" />
<result property="processDefinitionKey" column="PROC_DEF_KEY_" jdbcType="VARCHAR" />
<result property="processDefinitionVersion" column="PROC_DEF_VERSION_" jdbcType="INTEGER" />
<result property="deploymentId" column="DEPLOYMENT_ID_" jdbcType="VARCHAR" />
<result property="startTime" column="START_TIME_" jdbcType="TIMESTAMP" />
<result property="endTime" column="END_TIME_" jdbcType="TIMESTAMP" />
<result property="durationInMillis" column="DURATION_" jdbcType="BIGINT" />
<result property="startUserId" column="START_USER_ID_" jdbcType="VARCHAR" />
<result property="startActivityId" column="START_ACT_ID_" jdbcType="VARCHAR" />
<result property="endActivityId" column="END_ACT_ID_" jdbcType="VARCHAR" />
<result property="superProcessInstanceId" column="SUPER_PROCESS_INSTANCE_ID_" jdbcType="VARCHAR" />
<result property="deleteReason" column="DELETE_REASON_" jdbcType="VARCHAR" />
<result property="tenantId" column="TENANT_ID_" jdbcType="VARCHAR" />
<result property="name" column="NAME_" jdbcType="VARCHAR" />
<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" />
</resultMap>
<resultMap id="historicProcessInstanceAndVariablesResultMap" type="org.flowable.engine.impl.persistence.entity.HistoricProcessInstanceEntityImpl">
<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="PROC_DEF_NAME_" jdbcType="VARCHAR" />
<result property="processDefinitionKey" column="PROC_DEF_KEY_" jdbcType="VARCHAR" />
<result property="processDefinitionVersion" column="PROC_DEF_VERSION_" jdbcType="INTEGER" />
<result property="deploymentId" column="DEPLOYMENT_ID_" jdbcType="VARCHAR" />
<result property="startTime" column="START_TIME_" jdbcType="TIMESTAMP" />
<result property="endTime" column="END_TIME_" jdbcType="TIMESTAMP" />
<result property="durationInMillis" column="DURATION_" jdbcType="BIGINT" />
<result property="startUserId" column="START_USER_ID_" jdbcType="VARCHAR" />
<result property="startActivityId" column="START_ACT_ID_" jdbcType="VARCHAR" />
<result property="endActivityId" column="END_ACT_ID_" jdbcType="VARCHAR" />
<result property="superProcessInstanceId" column="SUPER_PROCESS_INSTANCE_ID_" jdbcType="VARCHAR" />
<result property="deleteReason" column="DELETE_REASON_" jdbcType="VARCHAR" />
<result property="tenantId" column="TENANT_ID_" jdbcType="VARCHAR" />
<result property="name" column="NAME_" jdbcType="VARCHAR" />
<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" />
<collection property="queryVariables" column="EXECUTION_ID_" javaType="ArrayList" ofType="org.flowable.variable.service.impl.persistence.entity.HistoricVariableInstanceEntityImpl">
<id property="id" column="VAR_ID_"/>
<result property="name" column="VAR_NAME_" javaType="String" jdbcType="VARCHAR" />
<result property="variableType" 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>
<!-- HISTORIC PROCESS INSTANCE SELECT -->
<select id="selectHistoricProcessInstance" resultMap="historicProcessInstanceResultMap">
select * from ${prefix}ACT_HI_PROCINST where PROC_INST_ID_ = #{processInstanceId, jdbcType=VARCHAR}
</select>
<select id="selectHistoricProcessInstanceIdsByProcessDefinitionId" parameterType="org.flowable.common.engine.impl.db.ListQueryParameterObject" resultType="string">
select ID_
from ${prefix}ACT_HI_PROCINST
where PROC_DEF_ID_ = #{parameter}
</select>
<select id="selectHistoricProcessInstanceIdsBySuperProcessInstanceId" parameterType="org.flowable.common.engine.impl.db.ListQueryParameterObject" resultMap="historicProcessInstanceResultMap">
select *
from ${prefix}ACT_HI_PROCINST
where SUPER_PROCESS_INSTANCE_ID_ = #{parameter}
</select>
<select id="selectHistoricProcessInstancesByQueryCriteria" parameterType="org.flowable.engine.impl.HistoricProcessInstanceQueryImpl" resultMap="historicProcessInstanceResultMap">
<if test="firstResult != null and firstResult >= 0">${limitBefore}</if>
select distinct RES.* <if test="firstResult != null and firstResult >= 0">${limitBetween}</if>, DEF.KEY_ as PROC_DEF_KEY_, DEF.NAME_ as PROC_DEF_NAME_, DEF.VERSION_ as PROC_DEF_VERSION_, DEF.DEPLOYMENT_ID_ as DEPLOYMENT_ID_
<include refid="selectHistoricProcessInstancesByQueryCriteriaSql"/>
${orderBy}
<if test="firstResult != null and firstResult >= 0">${limitAfter}</if>
</select>
<select id="selectHistoricProcessInstanceCountByQueryCriteria" parameterType="org.flowable.engine.impl.HistoricProcessInstanceQueryImpl" resultType="long">
select count(distinct RES.ID_)
<include refid="selectHistoricProcessInstancesByQueryCriteriaSql"/>
</select>
<sql id="selectHistoricProcessInstancesByQueryCriteriaSql">
from ${prefix}ACT_HI_PROCINST RES
left outer join ${prefix}ACT_RE_PROCDEF DEF on RES.PROC_DEF_ID_ = DEF.ID_
<include refid="commonSelectHistoricProcessInstancesByQueryCriteriaSql"/>
</sql>
<select id="selectHistoricProcessInstancesWithVariablesByQueryCriteria" parameterType="org.flowable.engine.impl.HistoricProcessInstanceQueryImpl" resultMap="historicProcessInstanceAndVariablesResultMap">
<include refid="selectHistoricProcessInstancesWithVariablesByQueryCriteriaColumns"/>
<include refid="selectHistoricProcessInstancesWithVariablesByQueryCriteriaSql"/>
${orderBy}
<if test="firstResult != null and firstResult >= 0">${limitAfter}</if>
</select>
<sql id="selectHistoricProcessInstancesWithVariablesByQueryCriteriaColumns">
<if test="firstResult != null and firstResult >= 0">${limitBefore}</if>
<if test="_databaseId != 'db2' and _databaseId != 'mssql'">
select distinct RES.*, DEF.KEY_ as PROC_DEF_KEY_, DEF.NAME_ as PROC_DEF_NAME_, DEF.VERSION_ as PROC_DEF_VERSION_, DEF.DEPLOYMENT_ID_ as DEPLOYMENT_ID_,
VAR.ID_ as VAR_ID_,
VAR.NAME_ as VAR_NAME_,
VAR.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.LAST_UPDATED_TIME_ as VAR_LAST_UPDATED_TIME_,
VAR.LONG_ as VAR_LONG_
<if test="firstResult != null and firstResult >= 0">${limitBetween}</if>
</if>
<if test="_databaseId == 'db2' || _databaseId == 'mssql'">
select distinct TEMPRES_ID_ as ID_,
TEMPRES_REV_ as REV_,
TEMPRES_BUSINESS_KEY_ as BUSINESS_KEY_,
TEMPRES_PROC_DEF_ID_ as PROC_DEF_ID_,
TEMPRES_START_TIME_ as START_TIME_,
TEMPRES_END_TIME_ as END_TIME_,
TEMPRES_DURATION_ as DURATION_,
TEMPRES_START_USER_ID_ as START_USER_ID_,
TEMPRES_START_ACT_ID_ as START_ACT_ID_,
TEMPRES_END_ACT_ID_ as END_ACT_ID_,
TEMPRES_SUPER_PROCESS_INSTANCE_ID_ as SUPER_PROCESS_INSTANCE_ID_,
TEMPRES_DELETE_REASON_ as DELETE_REASON_,
TEMPRES_NAME_ as NAME_,
TEMPRES_TENANT_ID_ as TENANT_ID_,
TEMPRES_PROC_DEF_KEY_ as PROC_DEF_KEY_,
TEMPRES_PROC_DEF_NAME_ as PROC_DEF_NAME_,
TEMPRES_PROC_DEF_VERSION_ as PROC_DEF_VERSION_,
TEMPRES_DEPLOYMENT_ID_ as DEPLOYMENT_ID_,
TEMPVAR_ID_ as VAR_ID_,
TEMPVAR_NAME_ as VAR_NAME_,
TEMPVAR_TYPE_ as VAR_TYPE_,
TEMPVAR_REV_ as VAR_REV_,
TEMPVAR_PROC_INST_ID_ as VAR_PROC_INST_ID_,
TEMPVAR_EXECUTION_ID_ as VAR_EXECUTION_ID_,
TEMPVAR_TASK_ID_ as VAR_TASK_ID_,
TEMPVAR_BYTEARRAY_ID_ as VAR_BYTEARRAY_ID_,
TEMPVAR_DOUBLE_ as VAR_DOUBLE_,
TEMPVAR_TEXT_ as VAR_TEXT_,
TEMPVAR_TEXT2_ as VAR_TEXT2_,
TEMPVAR_LAST_UPDATED_TIME_ as VAR_LAST_UPDATED_TIME_,
TEMPVAR_LONG_ as VAR_LONG_
<if test="firstResult != null and firstResult >= 0">${limitOuterJoinBetween}</if>
RES.ID_ as TEMPRES_ID_,
RES.REV_ as TEMPRES_REV_,
RES.BUSINESS_KEY_ as TEMPRES_BUSINESS_KEY_,
RES.PROC_DEF_ID_ as TEMPRES_PROC_DEF_ID_,
RES.PROC_INST_ID_ as TEMPRES_PROC_INST_ID_,
RES.START_TIME_ as TEMPRES_START_TIME_,
RES.END_TIME_ as TEMPRES_END_TIME_,
RES.DURATION_ as TEMPRES_DURATION_,
RES.START_USER_ID_ as TEMPRES_START_USER_ID_,
RES.START_ACT_ID_ as TEMPRES_START_ACT_ID_,
RES.END_ACT_ID_ as TEMPRES_END_ACT_ID_,
RES.SUPER_PROCESS_INSTANCE_ID_ as TEMPRES_SUPER_PROCESS_INSTANCE_ID_,
RES.DELETE_REASON_ as TEMPRES_DELETE_REASON_,
RES.NAME_ as TEMPRES_NAME_,
RES.TENANT_ID_ as TEMPRES_TENANT_ID_,
DEF.KEY_ as TEMPRES_PROC_DEF_KEY_,
DEF.NAME_ as TEMPRES_PROC_DEF_NAME_,
DEF.VERSION_ as TEMPRES_PROC_DEF_VERSION_,
DEF.DEPLOYMENT_ID_ as TEMPRES_DEPLOYMENT_ID_,
VAR.ID_ as TEMPVAR_ID_,
VAR.NAME_ as TEMPVAR_NAME_,
VAR.VAR_TYPE_ as TEMPVAR_TYPE_,
VAR.REV_ as TEMPVAR_REV_,
VAR.PROC_INST_ID_ as TEMPVAR_PROC_INST_ID_,
VAR.EXECUTION_ID_ as TEMPVAR_EXECUTION_ID_,
VAR.TASK_ID_ as TEMPVAR_TASK_ID_,
VAR.BYTEARRAY_ID_ as TEMPVAR_BYTEARRAY_ID_,
VAR.DOUBLE_ as TEMPVAR_DOUBLE_,
VAR.TEXT_ as TEMPVAR_TEXT_,
VAR.TEXT2_ as TEMPVAR_TEXT2_,
VAR.LAST_UPDATED_TIME_ as TEMPVAR_LAST_UPDATED_TIME_,
VAR.LONG_ as TEMPVAR_LONG_
</if>
</sql>
<sql id="selectHistoricProcessInstancesWithVariablesByQueryCriteriaSql">
from ${prefix}ACT_HI_PROCINST RES
left outer join ${prefix}ACT_RE_PROCDEF DEF on RES.PROC_DEF_ID_ = DEF.ID_
<if test="includeProcessVariables">
left outer join ${prefix}ACT_HI_VARINST VAR ON RES.PROC_INST_ID_ = VAR.EXECUTION_ID_
</if>
<include refid="commonSelectHistoricProcessInstancesByQueryCriteriaSql"/>
</sql>
<delete id="bulkDeleteHistoricProcessInstances">
delete from ${prefix}ACT_HI_PROCINST
<where>
<include refid="commonInstanceQuerySql">
<property name="queryTablePrefix" value=""/>
</include>
<foreach item="orQueryObject" index="orIndex" collection="orQueryObjects">
and
<trim prefix="(" prefixOverrides="OR" suffix=")">
<include refid="commonInstanceOrQuerySql">
<property name="queryTablePrefix" value=""/>
</include>
</trim>
</foreach>
</where>
</delete>
<sql id="commonSelectHistoricProcessInstancesByQueryCriteriaSql">
<foreach collection="queryVariableValues" index="index" item="queryVariableValue">
<if test="!queryVariableValue.operator.equals('EXISTS') && !queryVariableValue.operator.equals('NOT_EXISTS')">
inner join ${prefix}ACT_HI_VARINST A${index} on RES.PROC_INST_ID_ = A${index}.PROC_INST_ID_
</if>
</foreach>
<foreach collection="orQueryObjects" index="orIndex" item="orQueryObject">
<if test="orQueryObject.processKeyNotIn != null || orQueryObject.processDefinitionKey != null || orQueryObject.processDefinitionCategory != null || orQueryObject.processDefinitionName != null || orQueryObject.processDefinitionVersion != null || (orQueryObject.processDefinitionKeyIn != null && orQueryObject.processDefinitionKeyIn.size() > 0)">
inner join ${prefix}ACT_RE_PROCDEF DEF_OR${orIndex} on RES.PROC_DEF_ID_ = DEF_OR${orIndex}.ID_
</if>
<if test="orQueryObject.deploymentId != null || (orQueryObject.deploymentIds != null && orQueryObject.deploymentIds.size() > 0)">
left outer join ${prefix}ACT_RE_PROCDEF DEPLOY_P_OR${orIndex} ON RES.PROC_DEF_ID_ = DEPLOY_P_OR${orIndex}.ID_
</if>
<if test="orQueryObject.queryVariableValues != null && orQueryObject.queryVariableValues.size() > 0">
<if test="orQueryObject.hasValueComparisonQueryVariables()">
left outer join ${prefix}ACT_HI_VARINST A_OR${orIndex} on RES.PROC_INST_ID_ = A_OR${orIndex}.PROC_INST_ID_
</if>
</if>
</foreach>
<if test="withJobException">
left outer join ${prefix}ACT_RU_TIMER_JOB JOB ON RES.PROC_INST_ID_ = JOB.PROCESS_INSTANCE_ID_
</if>
<where>
<include refid="commonInstanceQuerySql">
<property name="queryTablePrefix" value="RES."/>
</include>
<if test="processDefinitionKey != null">
and DEF.KEY_ = #{processDefinitionKey}
</if>
<if test="processDefinitionKeyIn != null && processDefinitionKeyIn.size() > 0">
and DEF.KEY_ IN
<foreach item="definition" index="index" collection="processDefinitionKeyIn"
open="(" separator="," close=")">
#{definition}
</foreach>
</if>
<if test="processDefinitionVersion != null">
and DEF.VERSION_ = #{processDefinitionVersion}
</if>
<if test="processDefinitionCategory != null">
and DEF.CATEGORY_ = #{processDefinitionCategory}
</if>
<if test="processDefinitionName != null">
and DEF.NAME_ = #{processDefinitionName}
</if>
<if test="deploymentId != null">
and DEF.DEPLOYMENT_ID_ = #{deploymentId}
</if>
<if test="deploymentIds != null && deploymentIds.size() > 0">
and DEF.DEPLOYMENT_ID_ IN
<foreach item="deployment" index="index" collection="deploymentIds"
open="(" separator="," close=")">
#{deployment}
</foreach>
</if>
<if test="processKeyNotIn != null">
<foreach collection="processKeyNotIn" index="index" item="procDefKey">
and DEF.KEY_ not like #{procDefKey}${wildcardEscapeClause}
</foreach>
</if>
<foreach collection="queryVariableValues" index="index" item="queryVariableValue">
<choose>
<when test="queryVariableValue.operator.equals('EXISTS')">
and EXISTS (select ID_ from ${prefix}ACT_HI_VARINST where NAME_ = #{queryVariableValue.name} and RES.PROC_INST_ID_ = PROC_INST_ID_)
</when>
<when test="queryVariableValue.operator.equals('NOT_EXISTS')">
and NOT EXISTS (select ID_ from ${prefix}ACT_HI_VARINST where NAME_ = #{queryVariableValue.name} and RES.PROC_INST_ID_ = PROC_INST_ID_)
</when>
<otherwise>
<if test="queryVariableValue.name != null">
<!-- Match-all variable-names when name is null -->
and A${index}.NAME_= #{queryVariableValue.name}
</if>
<if test="queryVariableValue.needsTypeCheck()">
and A${index}.VAR_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(A${index}.TEXT_)
</when>
<otherwise>
and (A${index}.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 A${index}.TEXT_ is null
</if>
)
</if>
<if test="queryVariableValue.textValue2 != null">
and A${index}.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 (A${index}.LONG_
<include refid="executionVariableOperator" />
#{queryVariableValue.longValue}
<if test="queryVariableValue.operator.equals('NOT_EQUALS') || queryVariableValue.operator.equals('NOT_EQUALS_IGNORE_CASE')">
or A${index}.LONG_ is null
</if>
)
</if>
<if test="queryVariableValue.doubleValue != null">
and (A${index}.DOUBLE_
<include refid="executionVariableOperator" />
#{queryVariableValue.doubleValue}
<if test="queryVariableValue.operator.equals('NOT_EQUALS') || queryVariableValue.operator.equals('NOT_EQUALS_IGNORE_CASE')">
or A${index}.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 (A${index}.TEXT_ is not null or A${index}.TEXT2_ is not null or A${index}.LONG_ is not null or A${index}.DOUBLE_ is not null or A${index}.BYTEARRAY_ID_ is not null)
</when>
<otherwise>
and A${index}.TEXT_ is null and A${index}.TEXT2_ is null and A${index}.LONG_ is null and A${index}.DOUBLE_ is null and A${index}.BYTEARRAY_ID_ is null
</otherwise>
</choose>
</if>
</otherwise>
</choose>
</foreach>
<foreach item="orQueryObject" index="orIndex" collection="orQueryObjects">
and
<trim prefix="(" prefixOverrides="OR" suffix=")">
<include refid="commonInstanceOrQuerySql">
<property name="queryTablePrefix" value="RES."/>
</include>
<if test="orQueryObject.processDefinitionKey != null">
or DEF_OR${orIndex}.KEY_ = #{orQueryObject.processDefinitionKey}
</if>
<if test="orQueryObject.processDefinitionKeyIn != null && orQueryObject.processDefinitionKeyIn.size() > 0">
or DEF_OR${orIndex}.KEY_ IN
<foreach item="definition" index="index" collection="orQueryObject.processDefinitionKeyIn"
open="(" separator="," close=")">
#{definition}
</foreach>
</if>
<if test="orQueryObject.processDefinitionVersion != null">
or DEF_OR${orIndex}.VERSION_ = #{orQueryObject.processDefinitionVersion}
</if>
<if test="orQueryObject.processDefinitionCategory != null">
or DEF_OR${orIndex}.CATEGORY_ = #{orQueryObject.processDefinitionCategory}
</if>
<if test="orQueryObject.processDefinitionName != null">
or DEF_OR${orIndex}.NAME_ = #{orQueryObject.processDefinitionName}
</if>
<if test="orQueryObject.deploymentId != null">
or DEPLOY_P_OR${orIndex}.DEPLOYMENT_ID_ = #{orQueryObject.deploymentId}
</if>
<if test="orQueryObject.deploymentIds != null && orQueryObject.deploymentIds.size() > 0">
or DEPLOY_P_OR${orIndex}.DEPLOYMENT_ID_ IN
<foreach item="deployment" index="index" collection="orQueryObject.deploymentIds"
open="(" separator="," close=")">
#{deployment}
</foreach>
</if>
<if test="orQueryObject.processKeyNotIn != null">
or
<trim prefix="(" prefixOverrides="AND" suffix=")">
<foreach collection="orQueryObject.processKeyNotIn" index="index" item="procDefKey">
and DEF_OR${orIndex}.KEY_ not like #{procDefKey}${wildcardEscapeClause}
</foreach>
</trim>
</if>
<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_HI_VARINST where NAME_ = #{queryVariableValue.name} and RES.PROC_INST_ID_ = PROC_INST_ID_)
</when>
<when test="queryVariableValue.operator.equals('NOT_EXISTS')">
and NOT EXISTS (select ID_ from ${prefix}ACT_HI_VARINST where NAME_ = #{queryVariableValue.name} and RES.PROC_INST_ID_ = PROC_INST_ID_)
</when>
<otherwise>
<if test="queryVariableValue.name != null">
<!-- Match-all variable-names when name is null -->
and A_OR${orIndex}.NAME_= #{queryVariableValue.name}
</if>
<if test="queryVariableValue.needsTypeCheck()">
and A_OR${orIndex}.VAR_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(A_OR${orIndex}.TEXT_)
</when>
<otherwise>
and (A_OR${orIndex}.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 A_OR${index}.TEXT_ is null
</if>
)
</if>
<if test="queryVariableValue.textValue2 != null">
and A_OR${orIndex}.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 (A_OR${orIndex}.LONG_
<include refid="executionVariableOperator" />
#{queryVariableValue.longValue}
<if test="queryVariableValue.operator.equals('NOT_EQUALS') || queryVariableValue.operator.equals('NOT_EQUALS_IGNORE_CASE')">
or A_OR${index}.LONG_ is null
</if>
)
</if>
<if test="queryVariableValue.doubleValue != null">
and (A_OR${orIndex}.DOUBLE_
<include refid="executionVariableOperator" />
#{queryVariableValue.doubleValue}
<if test="queryVariableValue.operator.equals('NOT_EQUALS') || queryVariableValue.operator.equals('NOT_EQUALS_IGNORE_CASE')">
or A_OR${index}.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 (A_OR${orIndex}.TEXT_ is not null or A_OR${orIndex}.TEXT2_ is not null or A_OR${orIndex}.LONG_ is not null or A_OR${orIndex}.DOUBLE_ is not null or A_OR${orIndex}.BYTEARRAY_ID_ is not null)
</when>
<otherwise>
and A_OR${orIndex}.TEXT_ is null and A_OR${orIndex}.TEXT2_ is null and A_OR${orIndex}.LONG_ is null and A_OR${orIndex}.DOUBLE_ is null and A_OR${orIndex}.BYTEARRAY_ID_ is null
</otherwise>
</choose>
</if>
</otherwise>
</choose>
</trim>
</foreach>
</trim>
</foreach>
<if test="withJobException">
and (JOB.EXCEPTION_MSG_ is not null or JOB.EXCEPTION_STACK_ID_ is not null)
</if>
</where>
</sql>
<sql id="commonInstanceQuerySql">
<if test="processInstanceId != null">
${queryTablePrefix}PROC_INST_ID_ = #{processInstanceId}
</if>
<if test="processInstanceIds != null and !processInstanceIds.isEmpty()">
and ${queryTablePrefix}PROC_INST_ID_ in
<foreach item="item" index="index" collection="processInstanceIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="processDefinitionId != null">
and ${queryTablePrefix}PROC_DEF_ID_ = #{processDefinitionId}
</if>
<if test="businessKey != null">
and ${queryTablePrefix}BUSINESS_KEY_ = #{businessKey}
</if>
<if test="businessKeyLike != null">
and ${queryTablePrefix}BUSINESS_KEY_ like #{businessKeyLike}${wildcardEscapeClause}
</if>
<if test="startedBefore != null">
and ${queryTablePrefix}START_TIME_ <= #{startedBefore}
</if>
<if test="startedAfter != null">
and ${queryTablePrefix}START_TIME_ >= #{startedAfter}
</if>
<if test="finishedBefore != null">
and ${queryTablePrefix}END_TIME_ <= #{finishedBefore}
</if>
<if test="finishedAfter != null">
and ${queryTablePrefix}END_TIME_ >= #{finishedAfter}
</if>
<if test="unfinished">
and ${queryTablePrefix}END_TIME_ IS NULL
</if>
<if test="finished">
and ${queryTablePrefix}END_TIME_ is not NULL
</if>
<if test="notDeleted">
and ${queryTablePrefix}DELETE_REASON_ IS NULL
</if>
<if test="deleted">
and ${queryTablePrefix}DELETE_REASON_ IS NOT NULL
</if>
<if test="involvedUser != null">
and (exists(select LINK.USER_ID_ from ${prefix}ACT_HI_IDENTITYLINK LINK where USER_ID_ = #{involvedUser} and LINK.PROC_INST_ID_ = ${queryTablePrefix}ID_))
</if>
<if test="involvedUserIdentityLink != null">
and EXISTS(select ID_ from ${prefix}ACT_HI_IDENTITYLINK I where I.PROC_INST_ID_ = ${queryTablePrefix}ID_ and
I.USER_ID_ = #{involvedUserIdentityLink.userId} and I.TYPE_ = #{involvedUserIdentityLink.type})
</if>
<if test="involvedGroups != null">
and EXISTS(
select ID_ from ${prefix}ACT_HI_IDENTITYLINK LINK where LINK.PROC_INST_ID_ = ${queryTablePrefix}ID_ and LINK.GROUP_ID_ in
<foreach item="involvedGroup" index="index" collection="involvedGroups" open="(" separator="," close=")">
#{involvedGroup}
</foreach>
)
</if>
<if test="involvedGroupIdentityLink != null">
and EXISTS(select ID_ from ${prefix}ACT_HI_IDENTITYLINK I where I.PROC_INST_ID_ = ${queryTablePrefix}ID_ and
I.GROUP_ID_ = #{involvedGroupIdentityLink.groupId} and I.TYPE_ = #{involvedGroupIdentityLink.type})
</if>
<if test="startedBy != null">
and ${queryTablePrefix}START_USER_ID_ = #{startedBy}
</if>
<if test="superProcessInstanceId != null">
and ${queryTablePrefix}SUPER_PROCESS_INSTANCE_ID_ = #{superProcessInstanceId}
</if>
<if test="excludeSubprocesses">
and ${queryTablePrefix}SUPER_PROCESS_INSTANCE_ID_ is null
</if>
<if test="callbackId != null">
and ${queryTablePrefix}CALLBACK_ID_ = #{callbackId}
</if>
<if test="callbackType != null">
and ${queryTablePrefix}CALLBACK_TYPE_ = #{callbackType}
</if>
<if test="referenceId != null">
and ${queryTablePrefix}REFERENCE_ID_ = #{referenceId}
</if>
<if test="referenceType != null">
and ${queryTablePrefix}REFERENCE_TYPE_ = #{referenceType}
</if>
<if test="tenantId != null">
and ${queryTablePrefix}TENANT_ID_ = #{tenantId}
</if>
<if test="tenantIdLike != null">
and ${queryTablePrefix}TENANT_ID_ like #{tenantIdLike}${wildcardEscapeClause}
</if>
<if test="withoutTenantId">
and (${queryTablePrefix}TENANT_ID_ = '' or ${queryTablePrefix}TENANT_ID_ is null)
</if>
<if test="name != null">
and ${queryTablePrefix}NAME_ = #{name}
</if>
<if test="nameLike != null">
and ${queryTablePrefix}NAME_ like #{nameLike}${wildcardEscapeClause}
</if>
<if test="nameLikeIgnoreCase != null">
and lower(${queryTablePrefix}NAME_) like #{nameLikeIgnoreCase}${wildcardEscapeClause}
</if>
</sql>
<sql id="commonInstanceOrQuerySql">
<if test="orQueryObject.processInstanceId != null">
${queryTablePrefix}PROC_INST_ID_ = #{orQueryObject.processInstanceId}
</if>
<if test="orQueryObject.processInstanceIds != null and !orQueryObject.processInstanceIds.isEmpty()">
or ${queryTablePrefix}PROC_INST_ID_ in
<foreach item="item" index="index" collection="orQueryObject.processInstanceIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="orQueryObject.processDefinitionId != null">
or ${queryTablePrefix}PROC_DEF_ID_ = #{orQueryObject.processDefinitionId}
</if>
<if test="orQueryObject.businessKey != null">
or ${queryTablePrefix}BUSINESS_KEY_ = #{orQueryObject.businessKey}
</if>
<if test="orQueryObject.businessKeyLike != null">
or ${queryTablePrefix}BUSINESS_KEY_ like #{orQueryObject.businessKeyLike}${wildcardEscapeClause}
</if>
<if test="orQueryObject.startedBefore != null">
or ${queryTablePrefix}START_TIME_ <= #{orQueryObject.startedBefore}
</if>
<if test="orQueryObject.startedAfter != null">
or ${queryTablePrefix}START_TIME_ >= #{orQueryObject.startedAfter}
</if>
<if test="orQueryObject.finishedBefore != null">
or (${queryTablePrefix}END_TIME_ is not NULL and ${queryTablePrefix}END_TIME_ <= #{orQueryObject.finishedBefore})
</if>
<if test="orQueryObject.finishedAfter != null">
or (${queryTablePrefix}END_TIME_ is not NULL and ${queryTablePrefix}END_TIME_ >= #{orQueryObject.finishedAfter})
</if>
<if test="orQueryObject.unfinished">
or ${queryTablePrefix}END_TIME_ IS NULL
</if>
<if test="orQueryObject.finished">
or ${queryTablePrefix}END_TIME_ is not NULL
</if>
<if test="orQueryObject.notDeleted">
or ${queryTablePrefix}DELETE_REASON_ IS NULL
</if>
<if test="orQueryObject.deleted">
or ${queryTablePrefix}DELETE_REASON_ IS NOT NULL
</if>
<if test="orQueryObject.involvedUser != null">
or (exists(select LINK.USER_ID_ from ${prefix}ACT_HI_IDENTITYLINK LINK where USER_ID_ = #{orQueryObject.involvedUser} and LINK.PROC_INST_ID_ = ${queryTablePrefix}ID_))
</if>
<if test="orQueryObject.involvedUserIdentityLink != null">
or EXISTS(select ID_ from ${prefix}ACT_HI_IDENTITYLINK I where I.PROC_INST_ID_ = ${queryTablePrefix}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_HI_IDENTITYLINK LINK where LINK.PROC_INST_ID_ = ${queryTablePrefix}ID_ and LINK.GROUP_ID_ in
<foreach item="involvedGroup" index="index" collection="orQueryObject.involvedGroups" open="(" separator="," close=")">
#{involvedGroup}
</foreach>
)
</if>
<if test="orQueryObject.involvedGroupIdentityLink != null">
or EXISTS(select ID_ from ${prefix}ACT_HI_IDENTITYLINK I where I.PROC_INST_ID_ = ${queryTablePrefix}ID_ and
I.GROUP_ID_ = #{orQueryObject.involvedGroupIdentityLink.groupId} and I.TYPE_ = #{orQueryObject.involvedGroupIdentityLink.type})
</if>
<if test="orQueryObject.startedBy != null">
or ${queryTablePrefix}START_USER_ID_ = #{orQueryObject.startedBy}
</if>
<if test="orQueryObject.superProcessInstanceId != null">
or ${queryTablePrefix}SUPER_PROCESS_INSTANCE_ID_ = #{orQueryObject.superProcessInstanceId}
</if>
<if test="orQueryObject.excludeSubprocesses">
or ${queryTablePrefix}SUPER_PROCESS_INSTANCE_ID_ is null
</if>
<if test="orQueryObject.callbackId != null">
or ${queryTablePrefix}CALLBACK_ID_ = #{orQueryObject.callbackId}
</if>
<if test="orQueryObject.callbackType != null">
or ${queryTablePrefix}CALLBACK_TYPE_ = #{orQueryObject.callbackType}
</if>
<if test="orQueryObject.referenceId != null">
or ${queryTablePrefix}REFERENCE_ID_ = #{orQueryObject.referenceId}
</if>
<if test="orQueryObject.referenceType != null">
or ${queryTablePrefix}REFERENCE_TYPE_ = #{orQueryObject.referenceType}
</if>
<if test="orQueryObject.tenantId != null">
or ${queryTablePrefix}TENANT_ID_ = #{orQueryObject.tenantId}
</if>
<if test="orQueryObject.tenantIdLike != null">
or ${queryTablePrefix}TENANT_ID_ like #{orQueryObject.tenantIdLike}${wildcardEscapeClause}
</if>
<if test="orQueryObject.withoutTenantId">
or (${queryTablePrefix}TENANT_ID_ = '' or ${queryTablePrefix}TENANT_ID_ is null)
</if>
<if test="orQueryObject.name != null">
or ${queryTablePrefix}NAME_ = #{orQueryObject.name}
</if>
<if test="orQueryObject.nameLike != null">
or ${queryTablePrefix}NAME_ like #{orQueryObject.nameLike}${wildcardEscapeClause}
</if>
<if test="orQueryObject.nameLikeIgnoreCase != null">
or lower(${queryTablePrefix}NAME_) like #{orQueryObject.nameLikeIgnoreCase}${wildcardEscapeClause}
</if>
</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="selectHistoricProcessInstanceByNativeQuery" parameterType="java.util.Map" resultMap="historicProcessInstanceResultMap">
<include refid="org.flowable.engine.db.common.selectByNativeQuery"/>
</select>
<select id="selectHistoricProcessInstanceCountByNativeQuery" parameterType="java.util.Map" resultType="long">
${sql}
</select>
</mapper>