Database varchar列的Grails-GORM映射约束

Database varchar列的Grails-GORM映射约束,database,grails,gorm,Database,Grails,Gorm,我正在审查以前为我的项目服务的员工制定的代码。在我查看他们的代码时,我遇到了许多类似于以下内容的域类约束: String title String notes static mapping = { ..... title column: 'title' notes column: 'notes' ..... } static constraints = { ..... title nullable: false, size: 1..50, bl

我正在审查以前为我的项目服务的员工制定的代码。在我查看他们的代码时,我遇到了许多类似于以下内容的
类约束:

String title
String notes

static mapping = {
    .....
    title column: 'title'
    notes column: 'notes'
    .....
}

static constraints = {
    .....
    title nullable: false, size: 1..50, blank: true
    notes nullable: true, size: 0..500, blank: true
    .....
}
我发现
null
值和空字符串是不同的,因此
null
blank
约束是不同的。但是,您真的应该将
0
指定为
nullable
列的最小长度,并将
1
指定给那些
非nullable
列吗


如果确实如此,那么与那些不使用类似约束的
有什么区别?在阅读它们的代码之前,我已经编写了许多
类,只使用了
可空
约束,它们工作得很好。

我认为约束上存在冗余

我会把它重构成这样:

static constraints = {
    .....
    title nullable: false, max:50
    notes nullable: true, max:500
    .....
}

blank
约束如何?当
nullable
约束设置为
true
时,是否应不使用
blank
约束?否,空白:空白基本上表示允许长度为零空白:假表示不允许长度为零