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

  1. those enforced @ database layer, e.g. nullability, max length
  2. 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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -