"Fossies" - the Fresh Open Source Software Archive

Member "grails-core-5.2.4/grails-docs/src/test/resources/docs/ref/Database Mapping/indexColumn.html" (14 Sep 2022, 61247 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)

indexColumn

Purpose

Customizes the index column definition of an indexed collection such as a List or Map

Examples

class Neo {

    static hasMany = [matrix: Integer]

    static mapping = {
        matrix indexColumn: [name: "the_matrix", type: Integer]
    }
}
def neo = new Neo()
neo.matrix = [(1): 30, (2): 42, (3): 23]
neo.save(flush: true)

Description

Usage: association_name(indexColumn:map)

Arguments:

  • name - The name of the column as a String

  • type (optional) - The Hibernate type.

  • sqlType (optional) - The underlying SQL type

  • enumType (optional) - The enum type in for type-safe Enum properties. Either ordinal or string.

  • index (optional) - The index name

  • unique (optional) - Whether it is unique

  • length (optional) - The length of the column

  • precision (optional) - The precision of the column

  • scale (optional) - The scale of the column

By default when mapping an indexed collection such as a Map or List the index is stored in a column called association_name_idx which is an integer type in the case of lists and a String in the case of maps. You can alter how the index column is mapped using the indexColumn argument:

static mapping = {
    matrix indexColumn: [name: "the_matrix", type: Integer]
}