////
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
////

== create-domain-class

=== Purpose


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


=== Examples

[source,groovy]
----
grails create-domain-class
grails create-domain-class Book
grails create-domain-class org.bookstore.Book
----

=== Description

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 link:{guidePath}GORM.html[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 link:{guidePath}conf.html#config[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.

Usage:
[source,groovy]
----
grails create-domain-class <<name>>
----
