[英]How to compare collection item using createCriteria?
Registration domain has a collection of discounts. 注册域具有折扣集合。
static hasMany = [ discounts: Discount]
I want to extract all Registrations that have a particular discount applied. 我想提取所有具有特定折扣的注册。
In the following code i want to get all registrations whose collection has the discount of id disid. 在下面的代码中,我想获取所有集合的ID折扣为id disid的所有注册。 How can i achieve that? 我该如何实现? I appreciate any help! 感谢您的帮助!
def disid = Discount.get(1).id
def regs = Registration.createCriteria().list(){
eq('compositeEvent', cod.compositeEvent)
}
Try this: 尝试这个:
def disid = Discount.get(1).id
def regs = Registration.withCriteria() {
discounts {
eq 'id', disid
}
}
See http://emmanuelrosa.com/articles/gorm-for-sqladdicts-where-clause/ 参见http://emmanuelrosa.com/articles/gorm-for-sqladdicts-where-clause/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.