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
You can use this HQL query:
User.executeQuery( 'select u from User u where :follower in elements(u.followedUsers)', [follower: userInstance])
In my opinion, this syntax is much cleaner:
User.withCriteria { followedUsers{ eq('id', userInstance.id) } }