(快速參考)

indexColumn

目的

自訂索引集合的索引欄位定義,例如 ListMap

範例

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)

說明

用法:association_name(indexColumn:map)

引數

  • name - 欄位名稱,字串型別

  • type (選用) - Hibernate type

  • sqlType (選用) - 底層 SQL 型別

  • enumType (選用) - 型別安全的列舉屬性的列舉型別。ordinalstring

  • index (選用) - 索引名稱

  • unique (選用) - 是否唯一

  • length (選用) - 欄位長度

  • precision (選用) - 欄位精度

  • scale (選用) - 欄位小數位數

預設情況下,對應索引集合(例如 MapList)時,索引會儲存在名為 association_name_idx 的欄位中,在清單的情況下為 integer 型別,在映射的情況下為字串。你可以使用 indexColumn 引數變更索引欄位的對應方式

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