Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a 'contains' functionality on a collection property of a domain object for createCriteria?

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?

like image 932
Weezle Avatar asked Jul 13 '12 17:07

Weezle


1 Answers

Try this:

def l = c.list (max: maxVar, offset: offsetVar) {
    users {
        idEq(thisUser.id)
    }
}
like image 198
Chris Avatar answered Nov 11 '22 05:11

Chris