extending - Is it a good idea to extend a grails domain object? -


i need similar object grails domain object not need persisting. in order not have make changes in 2 places field changes, idea extend domain class can benefits of single set of fields. although related objects , collections need redone.

@cfrick spot on. groovy trait way go. can full example here (bad name project, know). here's quick example:

// mytrain.groovy: put in src/main/groovy/my/package package my.package  trait mytrait {     integer number     string }  // mydomainclass.groovy: goes other domain classes. package my.package  class mydomainclass implements mytrait {     /*        * number , properties available here.      * become table columns.      */        static constraints {         /*            * , can place constraints on them,          * had been declared in class.          */       }    } 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -