createCriteria的域对象的集合属性中是否存在“包含”功能? [英] Is there a 'contains' functionality on a collection property of a domain object for createCriteria?

查看:324
本文介绍了createCriteria的域对象的集合属性中是否存在“包含”功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Auction域对象和一个用户域对象。拍卖 hasMany 用户。



我想要做的是使用 createCriteria ,就像这样:

  def c = Auction.createCriteria()
def l = c.list(max:maxVar,offset:offsetVar){
包含(users,thisUser)
}

尽管包含不在可接受节点列表中: createCriteria描述页面

有没有办法实现这个功能?



要明确一点,有没有一种方法可以让指定的用户对象包含在拍卖的集合属性中?

解决方案

试试这个:

  def l = c.list(max:maxVar,offset:offsetVar){
users {
idEq(thisUser.id)
}
}


I have an Auction domain object and a User domain object. An Auction hasMany Users.

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)
}

Though, contains is not in the list of acceptable nodes: createCriteria description page.

Is there any way to implement this functionality?

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?

解决方案

Try this:

def l = c.list (max: maxVar, offset: offsetVar) {
    users {
        idEq(thisUser.id)
    }
}

这篇关于createCriteria的域对象的集合属性中是否存在“包含”功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆