Reputation: 161
How to make cascade to false for all grails domains at global level.
Also i would like to have the option to set it on specific save operation.
Upvotes: 2
Views: 238
Reputation: 56
For the first part of your question:
How to make cascade to false for all grails domains at global level.
It's a bit of an undocumented feature, but in your application.groovy
file you can add
grails.gorm.default.mapping = {
'*' cascade:'none'
}
Be aware that cascade validation will be disabled even if you use validate(deepValidate:true)
.
Note: Even with cascade validation disabled, if you validate manually a nested instance before the outer instance, then the validation of the outer instance will collect the errors of the nested instance. This caused me a fair amount of confusion.
I have only tested this in Grails 3.3, I'm not sure if it works in other versions.
Upvotes: 2