Reputation: 77
I have a domain class that looks like the following:
class Foo {
static hasMany = [bar: String]
}
The problem is that this creates a join table with a column of VARCHAR(255)
in MySQL, which much larger than I need it to be. In my example, bar is a Set not an indexed collection, so trying to use indexColumn does not work. joinTable does not have an attribute to change the column type/length. Is it possible to change to column size without changing the structure of the domain class?
Upvotes: 3
Views: 807
Reputation: 7619
You can also try sqlType
, like
class Foo {
static hasMany = [bar: String]
static mapping = {
names joinTable: [column: 'bar', sqlType: 'varchar(32)']
}
}
Upvotes: 2
Reputation: 1733
This works (tested with grails 2.4):
class Foo {
static hasMany = [
bars:String
]
static mapping = {
bars joinTable: [column: 'BARS_STRING', length: 112]
}
}
Upvotes: 5