Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error during @ToString processing: 'includes' property on Extended Object in Grails 6.2.0 #13489

Closed
amondel2 opened this issue Apr 25, 2024 · 3 comments

Comments

@amondel2
Copy link

Expected Behavior

class GenericDomainObject implements Serializable {

    String id

    private static final serialVersionUID = 1L

    def beforeValidate() {
        if(!id || id.equals(null)) {
            id  = Utils.getInstance().idGenerator()
        }
    }

    def beforeInsert() {
        if(!id || id.equals(null)) {
            id  = Utils.getInstance().idGenerator()
        }
    }
}
@ToString(includeNames=true,includes='id,dueDate')
class radmonDomain extends GenericDomainObject {
   Date dueDate
}

I have the following radmonDomain in my Domain Objects and GenericDomainObject in src/groovy above in Grails 6.1.2 this worked and the code compiled

Actual Behaviour

After upgrading to Grails 6.2.0 I get the following error during complieGroovy step

Error during @tostring processing: 'includes' property 'id' does not exist.
@ line 8, column 1.
@tostring(includeNames=true,includes='id,dueDate')
^

Steps To Reproduce

No response

Environment Information

OS: Linux
Java: JDK 17

Example Application

No response

Version

6.2.0

@amondel2
Copy link
Author

The easiest workaround is to just create a toString() method in the domain object but still wanted to report this.

@tylervz
Copy link

tylervz commented May 29, 2024

@amondel2 I actually get an error starting a Grails 5.3.5 project (with JDK 8) with the radmonDomain and GenericDomainObject Domain Objects defined as you have them above.

Error during @ToString processing: 'includes' property 'id' does not exist.
 @ line 7, column 1.
   @ToString(includeNames=true,includes='id,dueDate')

And I got the same error when trying to run a Grails 6.1.2 project (with JDK 11) with the radmonDomain and GenericDomainObject Domain Objects defined as you have them above.

To fix the error, you can modify the @ToString annotation in your radmonDomain class to include the includeSuperProperties=true attribute. This tells Groovy to also consider properties from superclasses when generating the toString() method.

@ToString(includeNames=true, includes='id,dueDate', includeSuperProperties=true)
class radmonDomain extends GenericDomainObject {

   Date dueDate
}

@amondel2
Copy link
Author

ahh thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants