Using grails 3.3.8
Any domainclass.save(flush:true,failOnError:true) does not get saved if a caught exception has been thrown in the service method where the save is being issued. i.e.
try {
//some code that throws exception
} catch (Exception exception) {
print 'some message'
}
domainclass.save(flush:true,failOnError:true)
I found a work around to the above. If you extract your try catch block and put it in a different method the domain class save does get persisted.
i.e.
callMethodThatContainsTryCatch()
domainClass.save()
instead of
try {
} catch (Exception exception) {
println "some exception"
}
domainClass.save()
It would then appear that any exception in your method rolls back of all gorm transactions within that method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With