枚举集查询关联我试图在Grails的1.2.1查询,发现所有产品均由租户类型。与Grails中
我的解决方案的工作,但是是非常低效的,首先我检索所有产品,然后找到一个给定的承租人所有匹配的结果。
我发现JIRA相关的bug:Enum as collection
class Product {
Set<TenantType> tenants
static hasMany = [tenants: TenantType]
}
enum TenantType {
BICYCLE,
MOTORCYCLE
}
def tenant = TenantType.BICYCLE
Product.list().findAll { product -> tenant in product.tenants }
有查询该数据的更有效的方法?
[Grails选择域对象基于枚举列表属性中的枚举值](http://stackoverflow.com/questions/4829823/grails-select-domain-objects-based -on-AN-枚举值在-AN-枚举列表属性) – 2015-10-06 10:25:24