List<ProcessToolSequence> seqList = hibernateSession.createCriteria(ProcessToolSequence.class)
.add(Restrictions.eq("processDefinitionName", processDefinitionName))
.add(Restrictions.eq("name", sequenceName))
.list();
ProcessToolSequence seq;
if (seqList.isEmpty()) {
seq = new ProcessToolSequence();
seq.setProcessDefinitionName(processDefinitionName);
seq.setName(sequenceName);
seq.setValue(1);
} else {
seq = seqList.get(0);
seq.setValue(seq.getValue() + 1);
}
hibernateSession.saveOrUpdate(seq);
hibernateSession.flush();
return seq.getValue();
}