How do I search for elements whose collection contains another element in Grails?

前端 未结 2 769
情深已故
情深已故 2021-02-07 21:53

Let\'s say I have a domain class called \"User\" which can follow other \"User\" objects. It does so having a field specified as:

def hasMany=[followedUsers:User         


        
2条回答
  •  一个人的身影
    2021-02-07 22:08

    In my opinion, this syntax is much cleaner:

    User.withCriteria { followedUsers{ eq('id', userInstance.id) } }
    

提交回复
热议问题