Reputation: 948
I'm new to Grails and not so familiar with how GORM maps columns to jdbc implementations. Basically I've got the following error:
org.h2.jdbc.JdbcSQLException
Message:
Value too long for column "KEYWORDS BINARY(255)": "X'aced0005737200116a6176612e7574696c2e486173684d61700507dac1c31660d103000246000a6c6f6164466163746f724900097468726573686f6c647870... (1871)"; SQL statement: insert into user (id, version, email, face_url, keywords, name, phone, tags, terminals, url, weibo_id, weibo_name) values (null, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [22001-176]
I tried several ways to change the way how this KEYWORD attribute is saved, such as
static constraints = {
...
keywords(type:'serializable')
}
I've also tried "maxSize:10000", "type:'text'", and the combination of these two. But none worked out and the error was exactly the same. The "keyword" attribute is just a HashMap of key=String, value=Double.
Generally, I'm just not sure what the best practice is to let Grails(Hibernate) store a hashmap. I believe there must be an easy setting somewhere rather than implementing a user defined persistence way myself for hibernate or grails. And I wonder why every time it seems to be converted to Binary(I did re-run the application to let the db drop and create all tables).
More details, my controller is just scaffold. Grails version is 2.4.4. H2db is used in dev environment.
Any advice is appreciated!
Upvotes: 2
Views: 2469
Reputation: 697
I guess you been defining keywords in static closure which is wrong, you should suppose to write it in static mapping like this
static mapping = {
keywords sqlType:'text'
}
hope this helps. Thanks
Upvotes: 1