"Fossies" - the Fresh Open Source Software Archive

Member "grails-core-5.2.4/grails-docs/src/test/resources/docs/ref/Database Mapping/table.html" (14 Sep 2022, 60425 Bytes) of package /linux/www/grails-core-5.2.4.tar.gz:


Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the grails-core-5.2.4.tar.gz project site itself.

(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)

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"
}