Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Grails 使用';布尔值';域类中的变量,未创建表_Grails_Gorm - Fatal编程技术网

Grails 使用';布尔值';域类中的变量,未创建表

Grails 使用';布尔值';域类中的变量,未创建表,grails,gorm,Grails,Gorm,我想在Grails中的域类中使用一个布尔属性和一个MySQL数据库。但是,当我运行此应用程序时,不会创建此表,也不会出现任何错误消息。但是,当我删除此属性read时,此表已成功创建 域类: class Message { Player author Player target String content boolean read static constraints = { target nullable: false

我想在Grails中的域类中使用一个布尔属性和一个MySQL数据库。但是,当我运行此应用程序时,不会创建此表,也不会出现任何错误消息。但是,当我删除此属性
read
时,此表已成功创建

域类:

class Message {

    Player author
    Player target
    String content
    boolean read

    static constraints = {
        target nullable: false
        author nullable: false
        content blank: false
    }

    static mapping = {
        read defaultValue: false
    }
}

我猜您正面临这个问题,因为
read
是保留关键字:

您可以将变量名
read
更改为其他内容,也可以使用
映射
闭包将列名更改为其他内容,例如:

class Message {

    Player author
    Player target
    String content
    boolean read

    static constraints = {
        target nullable: false
        author nullable: false
        content blank: false
    }

    static mapping = {
        read defaultValue: false, column: 'is_read'
    }
}
class Message {

    Player author
    Player target
    String content
    boolean read

    static constraints = {
        target nullable: false
        author nullable: false
        content blank: false
    }

    static mapping = {
        read defaultValue: false, column: 'is_read'
    }
}