Grails 更改 hasMany of Strings 的数据库列大小

Bil*_*Mad 3 grails grails-orm

我有一个域类,如下所示:

class Foo {
    static hasMany = [bar: String]
}
Run Code Online (Sandbox Code Playgroud)

问题是这会VARCHAR(255)在 MySQL 中创建一个带有列的连接表,这比我需要的要大得多。在我的示例中, bar 是 Set 而不是索引集合,因此尝试使用indexColumn不起作用。 joinTable没有更改列类型/长度的属性。是否可以在不更改域类结构的情况下更改列大小?

小智 5

这有效(使用 grails 2.4 测试):

class Foo {
    static hasMany = [
        bars:String
    ]

    static mapping = {
        bars joinTable: [column: 'BARS_STRING', length: 112]
    }
}
Run Code Online (Sandbox Code Playgroud)