« Return to Thread: Domain object retains erroneous properties when in a Service

Re: Domain object retains erroneous properties when in a Service

by Jeff Brown-14 :: Rate this Message:

Reply to Author | View in Thread

On Sat, Apr 11, 2009 at 9:45 AM, Michael Mallete <mrmallete@...> wrote:

> }
> service:
> service method:
> def update(book)
> {
> if(!book.hasErrors() || book.save())
> {
> //do something
> }
> else
> {
> throw new RuntimeException()
> }
> ..
> ..
> }

Do you want && in that condition, not || ?  I assume that your intent
is to throw the exception if save() fails.  That is, in order to _not_
throw the exception the object needs to not have errors _and_ save
needs to succeed.



jb
--
Jeff Brown
SpringSource
http://www.springsource.com/

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: Domain object retains erroneous properties when in a Service