Reputation: 50117
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!
Upvotes: 2
Views: 909
Reputation:
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
Upvotes: 0
Reputation: 187539
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
Upvotes: 1
Reputation: 2613
Sounds like a bug.
I'd enter the details into JIRA and get the answer from the source.
http://jira.codehaus.org/browse/GRAILS
Upvotes: 1