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 Stringtype
(optional) - The Hibernate type.sqlType
(optional) - The underlying SQL typeenumType
(optional) - The enum type in for type-safe Enum properties. Eitherordinal
orstring
.index
(optional) - The index nameunique
(optional) - Whether it is uniquelength
(optional) - The length of the columnprecision
(optional) - The precision of the columnscale
(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] }