grails - 如何让 Grails 将我的 String 字段映射到 Clob?

标签 grails groovy orm db2 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)
    }
} 

我的印象是,根据我为 maxSize 约束传递的足够大的值,Grails 会考虑使用 CLOB 而不是 VARCHAR,但我在控制台中收到此错误消息:

org.hibernate.HibernateException: Wrong column type in FOO for column STUFF. 
Found: clob, expected: varchar(40000)

映射上是否需要显式 sqlType?我尝试使用不同的 maxSize 值,并完全忽略它,没有区别。另外添加 sqlType: clobsqlType: text 不起作用。

我使用的是 Grails 1.3.7,使用 IBM DB2-Express。

最佳答案

找到答案了。没有像reading the documentation这样的找出一些东西。

有效的更改是将 clob 列的映射更改为

foo column: 'STUFF', type: "text"

关于grails - 如何让 Grails 将我的 String 字段映射到 Clob?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9268777/

相关文章:

logging - Grails:将调试日志记录发送到标准输出

Grails + Gpars.memoize().. 如何做内存?

android - 安卓代码注入(inject)

java - JPA - "no Metadata found for type"异常

hibernate - Joda 时间 DateTime 错误地存储在数据库中

grails - 如何使 grails 2 文档退出生成水平滚动条?

eclipse - Groovy-Grails Tool Suite (GGTS) 内容无法识别基本的 groovy

grails - 与三元和猫王的混淆

groovy - TestNG Groovy dependsOnMethods

python - 如何将此查询转换为 Peewee ORM?