With Grails, you have the save meta method attached to the Domain object. I have a list of objects that I want to save all together. But, if one of these fails, I want the whole ‘transaction’ to fail:
while(allDomainObjects) {
try {
thisObject.save()
}
catch(...) {
// end transaction
// kill all pending that weren't flushed yet?
}
}
flushAll()?
If it does not fail, I want to basically persist all objects that were saved in a ‘flush all’ method. On that same level, I want to kill all these pending saves if I have half way through the allDomainObjects iteration so that none of the calls persist.
I am using the default Hibernate/SiteMesh layers for my project. How do I handle these multiple domain save transactions??
Thanks!
This should help you out: Grails: how to structure transactions when I want to continue validating even after the transaction has already failed
In your case if you don’t want to keep processing to find all of your errors you check each object as you go through and return once you encounter an error.
As far as I know a
flushAll()method does not exist.