views:

74

answers:

1

Hi,

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.

is that possible to define that in grails or should i create a criteria before saving the form ? :)

thank you !!!

+3  A: 

http://grails.org/doc/1.1/ref/Constraints/unique.html

static constraints = {
   name unique: [ 'brand', 'color', 'supplier' ]
}
Siegfried Puchbauer