if(shouldRecoverFromOptimisticLockingFailure() && ERXEOAccessUtilities.recoverFromAdaptorException(object().editingContext(), ex)) { errorMessage = ERXLocalizer.currentLocalizer().localizedTemplateStringForKeyWithObject("CouldNotSavePleaseReapply", d2wContext());
if(shouldRecoverFromOptimisticLockingFailure()) { EOEnterpriseObject eo = ERXEOAccessUtilities.refetchFailedObject(editingContext(), ex); setErrorMessage(ERXLocalizer.currentLocalizer().localizedTemplateStringForKeyWithObject("CouldNotSavePleaseReapply", d2wContext())); validationFailedWithException(ex, eo, "CouldNotSavePleaseReapply");
    public boolean tryToSaveChanges(boolean validateObjects) {        if (log.isDebugEnabled()) log.debug("tryToSaveChanges() validateObjects: "+validateObjects+"  shouldSaveChanges: "+shouldSaveChanges());        boolean saved = false;        try {            if (!isListEmpty() && validateObjects && shouldValidateBeforeSave()) {                if (log.isDebugEnabled()) log.debug("tryToSaveChanges calling validateForSave");                editingContext().insertedObjects().makeObjectsPerformSelector(ValidateForInsertSelector, null);                editingContext().updatedObjects().makeObjectsPerformSelector(ValidateForSaveSelector, null);            }            if (!isListEmpty() && shouldSaveChanges() && editingContext().hasChanges())                ERXEOControlUtilities.saveChanges(editingContext());            saved = true;        } catch (NSValidation.ValidationException ex) {            errorMessage = ERXLocalizer.currentLocalizer().localizedTemplateStringForKeyWithObject("CouldNotSave", ex);            validationFailedWithException(ex, ex.object(), "saveChangesExceptionKey");        } catch(EOGeneralAdaptorException ex) {            if(shouldRecoverFromOptimisticLockingFailure() && ERXEOAccessUtilities.recoverFromAdaptorException(object().editingContext(), ex)) {                errorMessage = ERXLocalizer.currentLocalizer().localizedTemplateStringForKeyWithObject("CouldNotSavePleaseReapply", d2wContext());            } else {                throw ex;            }        }        return saved;    }