0

こんにちは、2 つの操作を実行するスプリング サービス メソッド (A メソッド) があります。まず、休止状態の dao メソッド (B メソッド) を介してデータをデータベースに保存します。次に、Spring-Activiti ワークフロー (C メソッド) に移動するように信号を送ります。次の段階へ。今、私は春のトランザクションマネージャを使用しています.そして私は以下のようにトランザクションを使用しています.だからここで私の質問は、ワークフローメソッドで何らかの例外がキャッチされた場合、データベースの変更を元に戻すべきではないということです..

 @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = Exception.class)
@Override
public WorkflowResponseBO saveDraft(PETIncidentBO pETIncident) throws DDMApplicationException {
Investigation investigation = savePETIncident(pETIncident);
WorkflowResponseBO workflowResponse = null;
if (pETIncident.getWorkflowId() == null) {
    workflowResponse = initiateWorkflow(pETIncident, investigation);
}
return workflowResponse;
}

@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false, rollbackFor = Exception.class)
private Investigation savePETIncident(PETIncidentBO pETIncident) throws DDMApplicationException {
LOGGER.info("Entered Method :: savePETIncident");
Investigation investigation = null;
try {
    if (pETIncident.getWorkflowId() != null) {
    investigation = investigationDao.findInvestigationByWorkflowId(pETIncident.getWorkflowId());
    }

    // Incident Data
    Incident incident = getIncidentDetails(investigation, pETIncident);

    // Investigation Data
    if (investigation == null) {
    investigation = new Investigation();
    investigation.setInvestigatedInvolvedPerson(getIncidentInvolvedPersonDetails(incident, pETIncident));
    MasterLookup allegedViolationType = null;
    allegedViolationType = masterLookupDao.findMasterLookupByShortDesc(DDMConstants.PROBATIONARY_TERMINATION_LOOKUP);
    investigation.setAllegedViolationType(allegedViolationType);
    CollectiveBargainingAgreement collectiveBargainingAgreement = null;
    collectiveBargainingAgreement = collectiveBargainingAgreementDao.findCollectiveBargainingAgreementbyId(pETIncident.getCba().getCollectiveBargainingAgreementId());
    investigation.setCollectiveBargainingAgreement(collectiveBargainingAgreement);
    investigation.setIncident(incident);
    }
    // updating the address and rehire status of the involved person
    investigation = updateInvesigationInvolvedPersonDetails(investigation, pETIncident);

    InvestigationUnstructuredContent content = getInvestigationUnstructuredContentDetails(investigation, pETIncident);

    content = getInvestigationUnstContentDeliveryDetails(pETIncident, content, investigation.getInvestigatedInvolvedPerson().getPerson());

    investigation.getInvestigationUnstConts().add(content);

    investigation = getInvestigationAssignedPersonDetails(investigation, incident, pETIncident);

    if (investigation.getInvestigationId() == null) {
    investigationDao.createinvestigation(investigation);
    } else {
    investigationDao.updateinvestigation(investigation);
    }

} catch (DDMDBException de) {
    LOGGER.error(de);
    DDMServicesExceptionHandler.handleException(de);
} catch (DDMApplicationException da) {
    LOGGER.error(da);
    DDMServicesExceptionHandler.handleException(da);
} catch (Exception e) {
    LOGGER.error(e);
    DDMServicesExceptionHandler.handleException(e);
}
LOGGER.info("Exited Method :: savePETIncident");
return investigation;
}
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false, rollbackFor = Exception.class)
private WorkflowResponseBO initiateWorkflow(PETIncidentBO pETIncident, Investigation investigation) throws DDMApplicationException {
// updating the workflow id in the investigation table
WorkflowResponseBO workflowResponse = null;
PETWorkflowDetailsBO petWorkflowDetails = new PETWorkflowDetailsBO();
petWorkflowDetails.setCbaId(investigation.getCollectiveBargainingAgreement().getCollectiveBargainingAgreementId().toString());
petWorkflowDetails.setInitiatorEmployeeId(pETIncident.getIncidentCreatorEmployeeId());
petWorkflowDetails.setInvovledPersonEmployeeId(pETIncident.getInvolvedPersonDeliveryDetails().getPerson().getEmployeeId());
petWorkflowDetails.setReasonForTermination(pETIncident.getReasonForTermination().getLookupShortDesc());
petWorkflowDetails.setTerminationDate(DdmDateUtils.dateToString(pETIncident.getTerminationDate(), DDMConstants.DISPLAY_DATE_FORMAT));
workflowResponse = petWorkflowService.reportProbationaryEmployeeTermination(petWorkflowDetails);
investigation.setWorkflowId(workflowResponse.getProcessId());
try {
    investigationDao.updateinvestigation(investigation);
} catch (DDMDBException e) {
    LOGGER.error("Error while updating investigation table");
    DDMServicesExceptionHandler.handleException(e);

}
if (workflowResponse == null) {
    workflowResponse = new WorkflowResponseBO();
    workflowResponse.setProcessId(pETIncident.getWorkflowId());
    workflowResponse.setTaskId(pETIncident.getTaskId());
}
return workflowResponse;
}   
4

1 に答える 1