My domain class looks like this:
package com.initech.tps
class Foo
{
String stuff
static mapping = {
// mapping to a legacy table as opposed to letting Grails create it
table name: 'FOO', schema: 'TPS'
id generator: 'sequence', params: [sequence: 'MY_SEQ'],
column: 'FOO_ID', sqlType: 'integer'
foo column: 'STUFF'
}
static constraints = {
stuff(nullable: true, maxSize: 40000)
}
}
I was under the impression Grails would figure out to use a CLOB instead of a VARCHAR based on my passing in a big enough value for the maxSize constraint, instead I get this error message in the console:
org.hibernate.HibernateException: Wrong column type in FOO for column STUFF.
Found: clob, expected: varchar(40000)
Do I need an explicit sqlType on the mapping? I tried using different values of maxSize, and leaving it out altogether, with no difference. Also adding sqlType: clob
or sqlType: text
doesn't work.
I'm on Grails 1.3.7, using IBM DB2-Express.
Found the answer. Nothing like reading the documentation to find something out.
The change that worked was changing the mapping for the clob column to
foo column: 'STUFF', type: "text"
I know it's too late, but for future references:
you just has to add a mapping
static mapping = { stuff type:'text' }
And that's all, grails change the data type to clob or any other that can hold large strings based in the database you're using.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With