« Return to Thread: "findOrCreateBy"

Re: "findOrCreateBy"

by Jeff Brown-14 :: Rate this Message:

Reply to Author | View in Thread

On Sat, Jul 4, 2009 at 12:09 PM, Moe<mohamed5432154321@...> wrote:

> Thats a good idea, the GORM labs and when it comes to the name of the method
> I think it sounds easy enough.
> On whether or not its necessary (although Robert don't want any input :P) I
> do think it would be good standard method for grails gorm, I am sure most
> folks have this code somewhere in their apps and should therefore be a
> standard one.
> def item = Item.findByName('someName') ?: new Item(name:'default',
> property:'something').save(flush:true)
>
> for example wouldn't work. It will return either true or false.

I don't think that will return a boolean.  I think that will return
null or an Item.  It will return an Item if findByName returns an item
or if save() is successful, otherwise return null.  Right?




Jeff
--
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: "findOrCreateBy"