Archive for the ‘groovy / grails’ Category

GORM: a silent failure …

Saturday, January 5th, 2008

I was pulling my hair out yesterday trying to determine why my application wasn’t saving all of it’s data to the database. There were no exception and only some of the data was getting written. I tested things again and again and I couldn’t see why the data wasn’t being saved.

I posted to the Nabble grails forum where I knew I would get a response quickly and it was suggested by Mike Brevoort that I try checking for errors from the save method. Of course this suggestion hit me like a brick since I should have known better than to ignore the return codes etc. I thought I was safe not worrying about this as I expected and exception to be thrown by someone if the data or relationships were invalid.

This is the approach suggested by Mike and I suggest you use it too, since a silent failure will take up a lot of your time:

if (!record.save(flush: true)) {
    println "GORM problems saving record $record"
    record.errors.each {
        println "$it"
    }
}

I could have saved myself a lot of time by checking the return codes / method result, but I’m also a little annoyed at the silent failure by GORM and Hibernate !

I hope this tip saves you a lot of stress and time.

Thanks Mike !

groovy / grails books …

Monday, June 25th, 2007

Recently I’ve been looking into groovy and grails as possible tools we can use at work for getting things done faster for our clients, whilst remaining close to Java so both we and they are comfortable. The following are some books I have read so far that I suggest are a great starting point for those interested in groovy and grails.

I’ll be doing some performance benchmarking between the two to get a feel for what to expect or cater for in using groovy / grails. So check back soon if your interested in the results.

Groovy in Action by Dierk Konig, Manning

grails-getting-started by Jason Rudolph You can download the eBook from http://infoq.com/minibooks/grails

The Definitive Guide to Grails by Graeme Keith Rocher, Apress.