How To Put A Constraint On Relationships In A Domain Class, In Grails?
-
12-11-2019 - |
Вопрос
I have a domain three domain class like this :
Tasks.groovy
class Tasks {
static belongsTo = [ user : User ]
//other fields
Date startDate
Date endDate
}
User.groovy
class User {
//relationships. . . .
static belongsTo = [ company : Company, role : Role, resource : Resource]
static hasMany = [ holidays : Holiday, tasks : Tasks]
//other fields
}
Holiday.groovy
class Holiday {
static belongsTo = User
Date startDate
Date endDate
//other fields
}
Now when I create a Tasks
instance, I want to put a constraint such that the Tasks
startDate
and endDate
doesn't fall within the User
's Holiday
s startDate
and endDate
. And throw and error if it has.
I want a way to put this constraint on my domain class itself(i.e on Tasks
).
Is it possible to do so?
Thanks in advance.
Нет правильного решения
Не связан с StackOverflow