(Quick Reference)



The create-domain-class command will create a domain and associated integration test for the given base name.


grails create-domain-class org.bookstore.Book


Creates a domain class for the given base name. For example, for a base name "org.bookstore.Book" a domain class called Book will be created in the grails-app/domain/org/bookstore directory.

A domain class represents the core model behind in your application and is typically mapped onto database tables. For more information on domain models in Grails refer to the chapter on GORM in the user guide.

The exact behaviour of the command depends on the argument you pass. If you don't specify a package (like "org.bookstore" in the example), then the name of the application will be used as the package. So if the application name is "my-app" and you run create-domain-class Book, then the command will create the file grails-app/domain/my/app/Book.groovy. Also, if you don't give your domain class an initial capital letter, it will be capitalized for you. So an argument of "org.bookstore.book" will result in a domain class called Book.

Note that this command is merely for convenience and you can also create domain classes in your favourite text editor or IDE if you choose.


grails create-domain-class [name]

Fired Events:

  • CreatedFile - When the domain class is created