动态更改流程实例的流程定义ID
public void changeProcessDefinitionId(String processInstanceId, String processDefinitionId) {
long count = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).count();
if (count == 0) {
throw new ServiceException("指定的流程定义不存在!");
}
Session session = processInstanceDao.getSession();
session.createSQLQuery("update ACT_RU_EXECUTION set PROC_DEF_ID_ = ? where PROC_INST_ID_ = ?")
.setParameter(0, processDefinitionId).setParameter(1, processInstanceId).executeUpdate();
session.createSQLQuery("update ACT_RU_TASK set PROC_DEF_ID_ = ? where PROC_INST_ID_ = ?")
.setParameter(0, processDefinitionId).setParameter(1, processInstanceId).executeUpdate();
session.createSQLQuery("update ACT_HI_PROCINST set PROC_DEF_ID_ = ? where PROC_INST_ID_ = ?")
.setParameter(0, processDefinitionId).setParameter(1, processInstanceId).executeUpdate();
session.createSQLQuery("update ACT_HI_TASKINST set PROC_DEF_ID_ = ? where PROC_INST_ID_ = ?")
.setParameter(0, processDefinitionId).setParameter(1, processInstanceId).executeUpdate();
session.createSQLQuery("update ACT_HI_ACTINST set PROC_DEF_ID_ = ? where PROC_INST_ID_ = ?")
.setParameter(0, processDefinitionId).setParameter(1, processInstanceId).executeUpdate();
}