createCriteria 的域对象的集合属性是否有“包含"功能? [英] Is there a 'contains' functionality on a collection property of a domain object for createCriteria?
本文介绍了createCriteria 的域对象的集合属性是否有“包含"功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个拍卖域对象和一个用户域对象.拍卖 hasMany
用户.
I have an Auction domain object and a User domain object. An Auction hasMany
Users.
我想使用 createCriteria
做的事情是这样的:
What I'd like to do, using createCriteria
, is something like this:
def c = Auction.createCriteria()
def l = c.list (max: maxVar, offset: offsetVar) {
contains("users", thisUser)
}
虽然,contains
不在可接受的节点列表中:createCriteria 描述页面.
Though, contains
is not in the list of acceptable nodes: createCriteria description page.
有没有办法实现这个功能?
Is there any way to implement this functionality?
需要明确的是,有没有办法让指定的 User 对象包含在 Auction 的集合属性中?
To be clear, is there a way to have the criteria be that a specified User object is contained within a collection property of the Auction?
推荐答案
试试这个:
def l = c.list (max: maxVar, offset: offsetVar) {
users {
idEq(thisUser.id)
}
}
这篇关于createCriteria 的域对象的集合属性是否有“包含"功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文