class Neo {
static hasMany = [matrix: Integer]
static mapping = {
matrix indexColumn: [name: "the_matrix", type: Integer]
}
}
indexColumn
用处
自定义索引集合(比如 List 或 Map)的索引列定义
示例
def neo = new Neo()
neo.matrix = [(1): 30, (2): 42, (3): 23]
neo.save(flush: true)
描述
用法:association_name(indexColumn:map)
参数
-
name- 列的名称,字符串形式 -
type(可选) - Hibernate type。 -
sqlType(可选) - 底层 SQL 类型 -
enumType(可选) - 类型安全的枚举属性的枚举类型。可能是ordinal或string。 -
index(可选) - 索引名称 -
unique(可选) - 是否唯一 -
length(可选) - 列的长度 -
precision(可选) - 列的精度 -
scale(可选) - 列的范围
默认情况下,映射索引集合(比如 Map 或 List)时,索引存储在名叫 association_name_idx 的列中,对于列表来说,此列是 integer 类型,对于映射来说,此列是字符串类型。你可以使用 indexColumn 参数更改索引列的映射方式
static mapping = {
matrix indexColumn: [name: "the_matrix", type: Integer]
}