java - Grails query association problem -
I'm having trouble writing a question for the following domain classes:
class Person {Static hasMany = [membership: membership]} class membership {static status = [person: person, group: group] date included date = new date (); Group group; Person person } Class group {stable [subscription: subscription]} Actually, I want to meet all the people who belong to the list of groups (let's group IDs (1 , 2) The trick here is that the person should be a member of both groups. I prefer a criterion query, but the HQL is also OK.
Note that something like Group.id (1,2) will not work because it can be in any group, both .
This is my normal HCl approach:
person.excut ("person From x where x (Select m.person membership meter WHERE to m.group =: Group 1) and in X (Subscription M. WHERE m.group =: Select from Group 2) ", [Group 1: Group.Jet (1), Group 2: Group.Jet (2)] Cheers
Comments
Post a Comment