Lets say i have two classes User and Role and a composite class UserRole.
This is a many to many relationship. With groovy i want to count the total users that have the only role USER_ROLE. How can i do so?
class User{
String name
}
class Role{
String authority
}
class UserRole{
User user
Role role
}
I have only put relevent information.
I want to form a gorm query such as
def result = UserRole.createCriteria().list(){
eq('role', Role.get(1)) //the Role with id 1 is USER_ROLE
}
so that i can get the count of users with the only role USER_ROLE. I appreciate any help! Thanks!