Nat*_*hes 6 db2 orm grails groovy grails-orm
我的域类看起来像这样:
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)
}
}
Run Code Online (Sandbox Code Playgroud)
我的印象是Grails会根据我为maxSize约束传递足够大的值而使用CLOB而不是VARCHAR,而是在控制台中收到此错误消息:
org.hibernate.HibernateException: Wrong column type in FOO for column STUFF.
Found: clob, expected: varchar(40000)
Run Code Online (Sandbox Code Playgroud)
我是否需要在映射上使用显式的sqlType?我尝试使用不同的maxSize值,并将其完全删除,没有区别.还添加sqlType: clob或sqlType: text不起作用.
我在Grails 1.3.7上,使用IBM DB2-Express.
Nat*_*hes 11
找到了答案.没有什么比阅读文档找到的东西更好的了.
有效的改变是将clob列的映射更改为
foo column: 'STUFF', type: "text"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7200 次 |
| 最近记录: |