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:

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