I have two tables. One contains a list of countries (ISO code and full name), the second one contains status of reg. Each reg entry can only have one country, but each country can have multiple reg entries. So far quite straight forward.
The regstat class is set up as follows:
class Regstat {
static hasOne = [country: Country]
String reg
int status
Date impdate
static constraints = {
reg(inList: ["FATCA", "ITC2014", "AEOI"])
}
static mapping = {
index: 'reg'
}
}
Here is the problem? I want to add a constraint which states that I only want a single entry of reg per country. So for example, a country can have a FATCA, IRC2014 or AEOI, but only one of each. Any suggestions how I would create such a constraint? Something along the lines of
constrain = {
reg+country(unique)
}