Reputation: 13
So I need to add a new domain file and corresponding controller to a Grails Project to create a prototype. I use this command:
grails create-domain-class com.grio.moment.MyTest
It creates MyTest.groovy successfully in the desired path. Also created this controller manually called MyTestController.
My question is now do I need to do additional configuration for database mapping or it automatically completes the configuration after I used the command in order to create the Domain Class?
Upvotes: 0
Views: 232
Reputation: 27200
You do not need to provide any additional configuration for database mapping. If the class is defined under grails-app/domain/
Grails will impose default mappings automatically.
If you want to customize the mapping you can do that by defining a static mapping
block in your domain class.
// grails-app/domain/demo/Person.groovy
package demo
class Person {
String firstName
String lastName
static mapping = {
// by default the table name would be 'person', this changes that...
table 'people'
}
}
See http://grails.org/doc/latest/guide/GORM.html#ormdsl for more details.
Upvotes: 1