【发布时间】:2015-02-25 15:00:06
【问题描述】:
在我的 Grails 项目中,我需要将特定的约束添加到我的域类对象的条目中。 域类如下:
class HealthServiceType {
String healthService;
static belongsTo = [doctor:Doctor]
static constraints = {
}
static mapping = {
}
}
我需要 healthService 不是空的,并且对于每个 Doctor 都是唯一的;也就是说,我可以为 healthService 设置多个“测试”值,但每个需要有不同的 Doctor 值。
是否可以在域类中执行此约束?还是我需要在 Controller 中实现一些检查?
【问题讨论】:
标签: grails constraints grails-domain-class grails-controller