grailsgrails-domain-class

What to do if you don't want any domain field to be displayed(int status) in DB. Grails


class Book {

String title
String name
int status

}


Solution

  • If you don't want grails to create the status field in the database, you add static transients = ['status'] to your class.

    class Book {
       String title
       String name
       int status
    
       static transients = ['status']
    }
    

    If you want to save status to the database but do not want the Scaffold to display the status on the screen, you can use status display: false in the constaints.

    class Book {
       String title
       String name
       int status
    
       static constraints = {
          status display: false
       }
    }