Search code examples
grailsgroovygrails-ormgrails-domain-class

Grails domain and @Canonical


I was using @ToString and @EqualsAndHashCode in my Grails domain classes. I found out about @Canonical and decided to use it instead. To my surprise I now get an error:

Unable to compile class xxx due to hash collision in constructors @ line -1, column -1. General error during class generation: java.util.NoSuchElementException

*java.util.NoSuchElementException
        at java.util.TreeMap$PrivateEntryIterator.nextEntry(TreeMap.java:1113)*

I thought this could be an issue with the old compiled classes so I deleted the target directory and tried again. Same issue.

Will @Canonical work with Grails domain classes?


Solution

  • No.

    See http://jira.grails.org/browse/GRAILS-8205

    17/Jan/14 4:43 AM The compiler will now generate an error if a domain class is marked with @Canonical.