Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails 3 @Delegate notation, using a domain object

Under Grails 2.4.4, we had classes we used as wrappers for domain objects.

They would look like this:

class Foo {
  @Delegate
  OurDomainClass ourDomainClass
  ...

}

This worked, but when trying to compile under Grails 3.0.11, we get this:

> Foo.groovy: 14: Can't have an abstract method in a non-abstract class.
> The class 'Foo' must be declared abstract or the method
> 'org.springframework.validation.Errors
> org_grails_datastore_gorm_GormValidateable__errors$get()' must be
> implemented.  @ line 14, column 1.    class Foo {    ^

Removing the @Delegate annotation will make compilation pass, but calls to methods of the underlying class obviously then do not work.

Is there a way to work around this or to achieve this same behavior and have it pass compilation under Grails 3?

like image 214
Sean LeBlanc Avatar asked Jan 06 '16 16:01

Sean LeBlanc


1 Answers

Does good old static hasMany = [] or static hasOne = [] won't do the job? Of course wrappers would be domain classes then too.

like image 138
Kamil Węglarz Avatar answered Nov 08 '22 12:11

Kamil Węglarz