I have a Foo domain class with an embedded Bar field:
class Foo {
Bar bar
static embedded=['bar']
}
class Bar {
String ham
}
Which gives me a foo table with a bar_ham column.
The problem is that my Foo.bar and Bar.ham have much longer names in reality, so the column ends up having more than 30 characters in length, which Oracle doesn’t like.
So how can I customize the name of the embedded column?
I’ve tried something like the following, but it didn’t work:
class Foo {
Bar bar
static embedded=['bar']
static mapping={
bar column:'b'
}
}
Specify the customized column name on the
Barclass, like so:Tested on Grails 2.0, this created a
Footable with column namesID,VERSION, andBAZ.This will affect all tables containing
Baz, however.Updates based on comment
Another options is to change the name of the mapped class to something shorter, like this:
This creates the column
B_BAZ_IS_REALLY_LONG, which at least helps.I don’t see any options for explicitly renaming embedded columns otherwise.