grails - GORM: Is it possible to load a domain object with errors? -
recently we've had new requirement check our domain objects errors after load them database la:
domaintype domain = domaintype.get(longdomaintypeid)
we must add error check on loaded domain:
if(domain.haserrors()) { //report errors , return failed }
if database constraints same domain constraints (not null, varchar length, etc) how possible have load error? check validate database connection still valid?
i'm curious know possibly expect go wrong here not catastrophic app/db connection failure...
there 2 types of gorm constraints
- those enforced @ database layer, e.g. nullability, max length
- those enforced programatically, e.g. implemented custom validators
assuming db schema in synch with gorm constraints it's possible data in database rejected (2) if:
- data written database isn't validated gorm
- constraints of type (2) added without performing correct data migration beforehand
Comments
Post a Comment