0

In grails, if you have the unique property on a domain that references another domain, and you want them to both be unique to each other, do you need to specifically say each one is unique to another? Or is that already done for you?

Example:

phoneNum unique: 'user'
user unique: 'phoneNum'
David Brewer
  • 1,864
  • 8
  • 25
  • 37
  • This might answer your question: http://stackoverflow.com/questions/7583380/grails-domain-class-unique-constraint-for-multiple-columns/7583673#7583673 – Joshua Moore Dec 08 '15 at 17:06
  • Not really. I understand what that is saying, but that's more for multiple domains being unique to one. I'm wondering if like in my example, if you need to define the unique-ness of each domain? (The example above is in one domain class) – David Brewer Dec 08 '15 at 17:26

1 Answers1

2

The first line is essentially the same as the second line. The only thing that will change is which property will receive the error if the unique constraint is violated.

foo.errors.hasFieldErrors('phoneNum') vs foo.errors.hasFieldErrors('user')

James Kleeh
  • 12,094
  • 5
  • 34
  • 61