HistoryTaskInstanceImpl historyTaskInstance = (HistoryTaskInstanceImpl)
session.load(HistoryTaskInstanceImpl.class, historyActivityInstanceDbId);
historyTaskInstance.setEndTime(Clock.getCurrentTime());
historyTaskInstance.setTransitionName(outcome);
HistoryTaskImpl historyTask = historyTaskInstance.getHistoryTask();
historyTask.setOutcome(outcome);
historyTask.setEndTime(Clock.getCurrentTime());
historyTask.setState(HistoryTask.STATE_COMPLETED);
session.update(historyTaskInstance);
}