(Quick Reference)

table

目的
Purpose

Customizes the name of the database table associated with the domain class

使用例
Examples

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

詳細
Description

Usage: table(string/map)
使用方法:
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 table names with underscores. So for example ProductReview becomes product_review. You can override this with the table method:

static mapping = {
    table "book_catalog"
}

You can also specify a schema and catalog:

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