-
Mar 20th, 2012, 02:52 PM
#1
Grails domain class
Hello
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
#2
Hi,
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
userIds.each() {
users.add( Users.get( it.IdUser ) )
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules