grails 中的列类型不起作用

Column type in grails not working

这是我的模型。

class Review {
String review
Date date
int numberOfComments
String status
static belongsTo = [game:Game, user:User]
static hasMany=[comment:Comment]
static mapping ={
    numberOfComments    defaultValue: "0"
    review type: 'text'
}

static constraints = {

}

当我输入 400 个字符的文本时出现此错误

我不知道为什么评论类型:'text' 不起作用。有人可以帮忙吗?

也许你可以使用 sqlType 代替

class Email {

    String body

    static mapping = {
        body sqlType: "longtext"
    }

你可以把它变成blob类型

static mapping = {
    review (type:’blob’)
}

注意 type 是 Grails 2.0 的默认属性,如果您使用较新版本的 grails,则应使用 sqlType.

在这里查看:http://grails.github.io/grails-doc/latest/ref/Database%20Mapping/column.html

事实上,grails GORM 有时会在更新列类型时出现问题,尤其是当它们包含任何数据时。尝试删除数据库中选定的 column/table 并重新启动应用程序。

还要确保您在 conf/DataSource 中进行了更改。groovy

dbCreate = "update"

dbCreate = "create-drop"

已编辑:首先我没有注意到您正在使用 h2 db。请查看 this answer 以了解 h2 数据库中的文本类型。