【发布时间】:2011-11-26 20:34:06
【问题描述】:
假设一个简单的 Grails 域类:
class Account {
String countryId;
String userName;
String password;
static constraints = {
...???...
}
}
对于特定的countryId,用户名要求是唯一的,因此两列必须有一个unique 约束。如何在 constraints 定义中表达这一点?
【问题讨论】:
-
我正在浏览网页,尤其是 stackoverflow,但没有找到答案。最后,我在Grails reference 中找到了解决方案,尽管所有其他 Grails 文档示例仅包含单列案例。不知道8小时内不能自答
标签: grails orm unique-constraint grails-domain-class grails-validation