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

StackOverflow https://stackoverflow.com/questions/11475009

  •  20-06-2021
  •  | 
  •  

문제

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)
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top