I have a domain and an enum like these:
class Order {
static hasMany = [statuses: StatusEnum]
}
public enum StatusEnum {
PAID("Paid")
PICKED_UP("Picked Up")
}
I'm trying to use withCriteria
to find an order which has been picked up:
Order.withCriteria {
statuses {
...
}
}
However, I'm getting a hibernate error:
org.hibernate.MappingException: collection was not an association
According to this SO question It seems that this is limitation of Hibernate (or at least it was at the time - 2011). There is even an unresolved Grails issue report: GRAILS-5989.
Does anyone have any suggestions on how to write a criteria for this relationship without going HQL (and preferably leaving the domain as is)?