Mar 20th, 2012, 02:52 PM
Grails domain class
I have three domain Classes
Users, Users-Roles (ID user->IdRole), RolesPrev(IdRole->RoleDescription)
How can I select all users from Users who has not role with description(3d table) Admin
How can join three tables in one queri/select/using domain class?
Is it possible?
Apr 19th, 2012, 08:57 AM
Since you didn't post the domain object code, I'm assuming that 'ID user->IdRole' are the columns in the Users-Roles table and not the relationship between the Users and Users-Roles table.
I had to do something similar in one of my projects. I'm sure there are more elegant ways to accomplish this, but this worked for me.
Set users = 
//Get the user ids out of the Users-Roles table
def userIds = UsersRoles.findAllByIdRole( RolesPrev.findByRoleDescription( "Admin" )?.idRole )
//Now get the users
users.add( Users.get( it.IdUser ) )