简体   繁体   English

如何定义域中是否有多个唯一字段?

[英]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.

相关问题 Grails域将属性名称映射到标识为ID但名称与属性不同的列 - Grails domain mapping property name to column identified as id but has different name than property 在HQL中对具有多个列的子查询执行内部联接? - Perform Inner Join on a subquery that has more than one column, in HQL? JPA实体具有多个相同类的对象 - JPA entity has more than one objects of the same class 我们可以在一个表中将一个FOREIGN KEY定义为多于两列吗? - Can we define One FOREIGN KEY as more than Two columns in one Table? Grails:在组合键上映射域类字段 - Grails: map domain class field on composite key Postgres如何进行多个交易 - Postgres how to make more than one transaction 如何判断当前tx(Hibernate)中是否删除了Grails / GORM域实例? - How can I tell if a Grails/GORM domain instance has been deleted in the current tx (Hibernate)? 如何映射一个本地查询,该查询的列多于一个表? - How to map a native query, that has more columns than a table? 如何在Grails中以一对多的方式定义首选(在主要意义上,默认)子对象? - How to define a preffered (in the sense of main, default) child object in a one to many in Grails? Hibernate JPA:一个表与多于10个表一对多,并导致性能下降 - Hibernate JPA: one table has one-to-many with more than 10 tables, and cause performance
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM