How can I enforce that all entity persistence operations in my Grails application happen via GORM data services, and never directly on my domain classes (e.g. the methods in GormEntityApi
and dynamic finders)?
Ideally the GormEntityApi
and dynamic finder methods would not be available on my domain classes at all, but I'd also accept a solution that neuters the methods by causing them all to throw e.g. an UnsupportedOperationException
.
I've done a bunch of internet searches, pored over the GORM documentation, and even dug around in the GORM code a bit, and I can't seem to find any information about this. Since data services provide all the same CRUD functionality as GormEntityApi
and dynamic finders, this seems like a reasonable thing to want to do. I feel like I must be missing something.
How can I enforce that all entity persistence operations in my Grails application happen via a GORM data services
There is no way to enforce that right now.
I've done a bunch of internet searches, pored over the GORM documentation, and even dug around in the GORM code a bit, and I can't seem to find any information about this.
We don't have support in the framework for doing that.
Since data services provide all the same CRUD functionality as GormEntityApi and dynamic finders, this seems like a reasonable thing to want to do. I feel like I must be missing something.
I don't think you are missing something. We have considered not adding the GormEntity
trait to domain classes by default, but right now that happens and we don't provide a mechanism for turning that off.