[英]how to define if domain has more than one unique field in grails?
I have domain that has more than one unique fields like the following 我的网域具有多个不重复的唯一字段,如下所示
class Shoes{
String name;
Brand brand ;
Color color ;
Supplier supplier ;
Integer size ;
BigDecimal price;
}
name, brand, color and supplier need to be unique ... so if there are product with same name brand color and supplier it would return false / validated as false. 名称,品牌,颜色和供应商必须唯一...因此,如果有具有相同名称的品牌颜色和供应商的产品,它将返回false /验证为false。
is that possible to define that in grails or should i create a criteria before saving the form ? 是否可以在grails中定义它,还是应该在保存表单之前创建条件? :)
:)
thank you !!! 谢谢 !!!
http://grails.org/doc/1.1/ref/Constraints/unique.html http://grails.org/doc/1.1/ref/Constraints/unique.html
static constraints = {
name unique: [ 'brand', 'color', 'supplier' ]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.