枚舉集查詢關聯我試圖在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