gpt4 book ai didi

grails - 在域类中使用 'Boolean'变量,未创建表

转载 作者:行者123 更新时间:2023-12-02 14:22:14 25 4
gpt4 key购买 nike

我想在带有MySQL数据库的Grails中的域类中使用 bool(boolean) 值属性。但是,当我运行此应用程序时,不会创建此表,并且没有任何错误消息。但是,当我删除此属性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是保留关键字according to MySQL documentation:

READ(R)

您可以将变量名 read更改为其他名称,也可以使用 mapping闭包将列名更改为其他名称,例如:
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'
}
}

关于grails - 在域类中使用 'Boolean'变量,未创建表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52293868/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com