views:

148

answers:

0

Looking for a way to include a conditional reference attached to a relation between two objects, for example

class Person {
String firstName
String lastName
static hasMany = [ readyNow: Role, readyLater : Role, emergencyReplacement: Role]
static belongsTo = Role
static constraints = {
}
String toString() {
    return firstName + " " + lastName
}
}
class Role {
String name
String location
static hasMany = [ readyNow: Person, readyLater: Person, emergencyReplacement: Person ]
static mappedBy = [readyNow: "readyNow", readyLater: "readyLater",
                    emergencyReplacement: "emergencyReplacement"]
}

This created a bidirectional many-to-many relationship, but if I want to do some kind of conditional reference on the readyLater relation, I'm not sure how I'd go about doing that.

Anyone have any ideas?