Question

The following Groovy code creates a GORM-persisted domain class called Foo when written to grails-app/domain/Foo.groovy:

class Foo {
  String someField
}

However, if I instead write "public class Foo" the class does NOT get GORM-persisted (i.e. no save() method injected, no database table created, etc.):

public class Foo {
  String someField
}

I'm running the latest stable release of Grails (1.1).

Question: Is this a bug or is it the expected behaviour? Why?

Update #1: Related sub-question: Am I the only one hitting this problem? It would be nice to know if anyone else is able to replicate this. Thanks!

Was it helpful?

Solution

Groovy classes are public by default (likewise for Groovy methods), so there should be no change in behaviour if you add public. However, I cannot reproduce this behaviour/bug in Grails 1.1.1

OTHER TIPS

Sounds like a bug.

I'd enter the details into JIRA and get the answer from the source.

http://jira.codehaus.org/browse/GRAILS

I am not getting this behavior on 1.3.3

check the "isDomainClass" method in DomainClassArtefactHandler.groovy. you will see (at least in 1.3.3) the only types that are excluded are closures and enums

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top