[英]No difference between nullable:true and nullable:false in Grails 1.3.6?
The following domain model definition .. 以下领域模型定义..
class Test {
String a
String b
static mapping = {
version(false)
table("test_table")
a(nullable: false)
b(nullable: true)
}
}
.. yields the following MySQL schema .. ..产生以下MySQL模式..
CREATE TABLE test_table (
id bigint(20) NOT NULL AUTO_INCREMENT,
a varchar(255) NOT NULL,
b varchar(255) NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Please note that a
and b
get identical MySQL column definitions despite the fact a
is defined as non-nullable and b
is nullable in the GORM mappings. 请注意, a
和b
得到尽管相同的MySQL列定义a
被定义为非null和b
是在GORM映射为空。
What am I doing wrong? 我究竟做错了什么? I'm running Grails 1.3.6. 我正在运行Grails 1.3.6。
nullable true/false goes in the static constraints
closure, not in the static mapping
. 可为空的true / false在static constraints
闭包中,而不在static mapping
。 See the constraints section of the Grails documentation. 请参阅Grails文档的约束部分 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.