"Fossies" - the Fresh Open Source Software Archive

Member "grails-core-5.2.4/grails-docs/src/test/resources/docs/ref/Command Line/create-domain-class.html" (14 Sep 2022, 60632 Bytes) of package /linux/www/grails-core-5.2.4.tar.gz:

Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the grails-core-5.2.4.tar.gz project site itself.

(Quick Reference)



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


grails create-domain-class
grails create-domain-class Book
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. The argument is optional, but if you don’t include it the command will ask you for the name of the domain class.

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 "bookstore" and you run create-domain-class Book, then the command will create the file grails-app/domain/bookstore/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.

If you want the command to default to a different package for domain classes, provide a value for grails.project.groupId in the runtime configuration.

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


grails create-domain-class <<name>>