I’m working with a Grails application where I have a domain class that has a hasMany
relationship with an enum. Here’s a simplified version of the code:
class Domain {
static hasMany = [
flags: Flags
]
}
enum Flags {
VALUE, OTHER_VALUE
}
I need to write a GORM query that finds all Domain
instances where the flags
collection contains only the OTHER_VALUE
enum value.
-
How can I correctly formulate a GORM query that returns
Domain
instances where theflags
collection only contains theOTHER_VALUE
enum? -
Is there a specific way to handle
hasMany
relationships with enums in GORM that I’m missing?
Looking for something like
Domain.where {
flags.contains(Flag.VALUE)
}.list()
however, the above isn’t okay.