【发布时间】:2015-02-18 23:38:48
【问题描述】:
我有两个域类:
class MyForm{
....
static hasMany = [items:MyFormItem]
}
class MyFormItem{
String type
static belongsTo=[myForm:MyForm]
}
我想查询 MyForm 并查找所有存在一种类型的项目但没有另一种类型的项目。
所以,我想找到所有 MyForm,其中有一个类型为“某物”的 MyFormItem,但它不能也有一个类型为“其他”的 MyFormItem。
我正在尝试使用 where 子句,但这似乎只是抓住了一切:
MyForm.where{
items{type=='something' && type!='other'}
}
有没有一种方法可以通过使用 GORM 的一个查询来做到这一点?
【问题讨论】:
标签: hibernate grails grails-orm grails-2.0