Grails -Domain Class

Domain Class :


  • Domain class is Model part of MVC in grails.
  • Domains are base of your projects.
  • Its a hibernate entity.
  • Grails Domain is always create in grails-app/domain folder under Grails project architecture. 
  • Domain represent  persistent entity that is mapped into your database table.
  • You can define different- different relation-ships between Domains like one two many ,many to many or   many to one(we will discuss these relation later).
  • You can create domain with command line with create-domain-class yourDomainClassName.
You can create domain with  you  IDE like (Domain will always create in grails-app/domain folder):

Class User 
             {
String name;
String email
String password
             }

It will create a user table in database.

The class name, by default, is mapped to the table name in lower case and separated by underscores instead of camel case so if  a domain class named UserAddress by default would map to a table named user_address . Each property maps to individual columns.

Comments

Popular Posts