editingContext.deleteObject(_object); editingContext.saveChanges(); _object=null;
if (editingContext instanceof EOSharedEditingContext) { if (ERXExtensions.isNewObject(_object)) { log.error("found a new object in a shared editing context "+editingContext); editingContext.deleteObject(_object); } else {  EOEditingContext ec = ERXEC.newEditingContext(); ec.lock(); try { ec.setSharedEditingContext(null); _object = EOUtilities.localInstanceOfObject(ec, _object); ec.deleteObject(_object); ec.saveChanges(); } finally { ec.unlock(); ec.dispose(); } } } else { editingContext.deleteObject(_object); editingContext.saveChanges(); _object=null; }
    public WOComponent nextPage(WOComponent sender) {        if (_object!=null && _object.editingContext()!=null) {            EOEditingContext editingContext=_object.editingContext();            try {                if (_dataSource != null)                    _dataSource.deleteObject(_object);                editingContext.deleteObject(_object);                editingContext.saveChanges();                _object=null;            } catch (NSValidation.ValidationException e) {                if(e instanceof ERXValidationException) {                    ERXValidationException ex = (ERXValidationException)e;                    D2WContext context = (D2WContext)sender.valueForKey("d2wContext");                    Object o = ex.object();                                        if(o instanceof EOEnterpriseObject) {                        EOEnterpriseObject eo = (EOEnterpriseObject)o;                        context.takeValueForKey( eo.entityName(),"entityName");                        context.takeValueForKey( ex.propertyKey(),"propertyKey");                    }                    ((ERXValidationException)e).setContext(context);                }                log.info("Validation Exception: "+ e + e.getMessage());                editingContext.revert();                String errorMessage = " Could not save your changes: "+e.getMessage()+" ";                ErrorPageInterface epf=D2W.factory().errorPage(sender.session());                epf.setMessage(errorMessage);                epf.setNextPage(followPage(sender));                return (WOComponent)epf;            }        }        return followPage(sender);    }