Hi, there must be a standard solution to this: I'd like to first see
whether a particular object already exists, i.e. use find by example.
If it is, I'd like to continue with the one that was found. If isn't
I'd like to try and save it. I'm thinking of using something like
Object.metaClass.safesave = {
def o = delegate.class.find(delegate)
if (!o) {
if (delegate.validate()) {
try {
o = delegate.save()
}
catch (Exception ex) {
println ex.getMessage()
delegate.errors.allErrors.each {
println it
}
}
} else {
delegate.errors.allErrors.each {
println it
}
}
}
o
}
Does that make sense or is there a better solution?
Cheers, Sven
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email