Grails中的列类型不起作用

Grails中的列类型不起作用

本文介绍了Grails中的列类型不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的模特.

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个字符的文本时,会产生此错误

我不知道为什么审阅类型:文本"不起作用.有人可以帮忙吗?

解决方案

实际上,GORM有时在更新列类型时会遇到问题,尤其是当它们包含任何数据时.尝试删除数据库中选定的列/表并重新启动应用程序.

还要确保已更改conf/DataSource.groovy

首先,我没有注意到您正在使用h2 db.请查看此答案以获取h2数据库中的文本类型. >

This is my model.

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 = {

}

when I inputted 400 character text it generated this error

I don't know why the review type: 'text' is not working. can someone help?

解决方案

In fact grails GORM sometimes have problems with updating column types, especially if they contain any data. Try to delete selected column/table in database and restart application.

Ensure also that you have changed in conf/DataSource.groovy

to

Edited: Firstly I didn't notice that you are using h2 db. Please check out this answer for text type in h2 database.

这篇关于Grails中的列类型不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 22:03