(Quick Reference)

table

Purpose

Customizes the name of the table to map to

Examples

class Book {
    static mapping = {
        table "book_catalog"
    }
}

Description

Usage: table(string/map)

Arguments:

  • name - The table name
  • schema (optional) - The table schema
  • catalog (optional) - The table catalog

By default the table that Grails maps a domain class is based on the class name. Grails will take a class name and convert Java style camel case names into underscores. So for example ProductReview will become product_review. You can change this with the table method:

static mapping = {
    table "book_catalog"
}

You can also specify a schema and catalog as follows:

static mapping = {
    table name:"book_catalog", schema:"dbo", catalog:"CRM"
}