数据截断:grails GSP字段列的数据太长

数据截断:grails GSP字段列的数据太长,grails,gsp,Grails,Gsp,我的项目中有这个域类。 这是一个样本 public class empHistory { String respField String addInfo static constraints = { respField(nullable: true, maxSize:100) updatedByUser(nullable: true, maxSize:100) } 在为两个字段提供字段值后,单击“确定”将显示以下错误 Data truncation

我的项目中有这个域类。 这是一个样本

public class empHistory {

String respField
String addInfo

static constraints = {

        respField(nullable: true, maxSize:100)
        updatedByUser(nullable: true, maxSize:100)
    }
在为两个字段提供字段值后,单击“确定”将显示以下错误

Data truncation: Data too long for column 'respField' in row 1

我认为您输入的值可能超过了指定的最大值。 例如,如果你需要扩大尺寸,你可以这样做

public class empHistory {

String respField
String addInfo

static constraints = {

        respField(nullable: true, maxSize:2000)
        updatedByUser(nullable: true, maxSize:2000)
    }

如果
dbcreate
状态为update,请将其更改为
create
create drop
,然后再次尝试运行应用程序。这是因为数据库已经在第一个约束中创建

您需要更改数据库中的列类型

L
是要存储的数据的长度

TINYBLOB, TINYTEXT :        L + 1 bytes, where L < 28
BLOB, TEXT :                L + 2 bytes, where L < 216
MEDIUMBLOB, MEDIUMTEXT :    L + 3 bytes, where L < 224
LONGBLOB, LONGTEXT :        L + 4 bytes, where L < 232
TINYBLOB,TINYTEXT:L+1字节,其中L<28
BLOB,TEXT:L+2字节,其中L<216
MEDIUMBLOB,MEDIUMTEXT:L+3字节,其中L<224
LONGBLOB,LONGTEXT:L+4字节,其中L<232
例如,如果您想上传大型图片或文件。您应该将默认的
TINYBLOB
数据类型更改为
LONGBLOB


如果您使用的是MySQL,您可以在这里找到更多信息:。

@user3679427开发环境中的
dbcreate
状态是什么。请参见
DataSOurce.groovy
文件中的。