Re: Need some advice on handling EO validation errors

Chuck Hill <[email protected]>
Newsgroups gmane.comp.web.webobjects.devel
Message-ID <[email protected]>
On Dec 7, 2007, at 7:48 AM, Greg Lappen wrote:

> Hi all,
>
> I just recently ran into an issue where my application tried to  
> save a new object to the database, the save failed, and every  
> subsequent save failed with the same error.  It seems that  
> WebObjects maintains a queue of updates/saves to write to the  
> database, and when one fails, it essentially clogs up the queue  
> because WO keeps trying to save it eveytime someone calls  
> saveChanges() on an editing context.  What I'd like to do is set up  
> a global exception handler in my application that runs whenever an  
> exception is not caught by my code, and in that error handler I  
> want to reset the whole EnterpriseObject stack - the cache, the  
> update/save queue, everything

Why stop there?  Why not just shell out a 'sudo reboot now' and be  
_really_ sure.


> - so that other work in the application can continue and not worry  
> about cache corruption or anything like that.
>
> Is this possible to do?  Anyone know how to do it?


Honestly, short of terminating the application or actually rebooting  
the server, I can't think of a _worse_ way to handle this.  You  
really need to get more familiar with EOEditingContext and  
EOValidation.  You code is simply not handling the save process  
correctly.

The situation you are seeing can also happen if you are editing in  
the session's default editing context, there is a validation error,  
and the user clicks away from the page.  Rather than worry about all  
that, I recommend never (or really, really rarely) performing any  
edits (create, delete, or update) in the session's default editing  
context.  Instead, use a peer editing context specific to the editing  
process (often that means specific to a page).  Note carefully that  
_you_ are responsible for locking and unlocking peer editing  
contexts.  The _only_ foolproof ways to do this are to use Project  
Wonder's ERXEC or the MultiECLockManager class.

Chuck

-- 

Practical WebObjects - for developers who want to increase their  
overall knowledge of WebObjects or who are trying to solve specific  
problems.
http://www.global-village.net/products/practical_webobjects
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.