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