Skip to content

Instantly share code, notes, and snippets.

@geosmart
Forked from henryyan/gist:5001893
Created April 18, 2013 14:17
Show Gist options
  • Save geosmart/5413041 to your computer and use it in GitHub Desktop.
Save geosmart/5413041 to your computer and use it in GitHub Desktop.
/**
* 更改流程实例的流程定义ID
* @param processInstanceId
* @param processDefinitionId
*/
@Transactional
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();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment