【发布时间】:2012-03-26 09:14:36
【问题描述】:
我正在 Grails 1.2.1 中尝试查询,按租户类型查找所有产品。
我的解决方案有效,但效率很低,首先我检索所有产品,然后找到给定租户的所有匹配结果。
我在 JIRA 中发现了一个相关的错误: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 hql grails-orm criteria