Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6332837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:21:23+00:00 2026-05-24T18:21:23+00:00

I am using the Spring Security Plugin . By default this plugin has created

  • 0

I am using the Spring Security Plugin. By default this plugin has created three classes in my project.

org.me.example.UserRole.UserRole
org.me.example.UserRole.User
org.me.example.UserRole.Role

The User and Role classes are unaware of each other, but the UserRole class has both a User and a Role object. The Role object has only one attribute, a string called authority.

My objective is to obtain all Users with a certain authority in a <g:select> statement.

Here is one of my attempts:

<g:select name="loggedBy.id" from="${org.me.example.UserRole.UserRole.list(fetch:[(role.authority):"ROLE_ADMIN"])}" optionKey="id" value=""  />

I do realize that this would return a UserRole list and not a User list. Is there anyway to “join” my classes so I can retrieve the data I want? Looking for the cleanest solution.

Update:

I think there was some confusion about what my classes look like, so here are the stripped down versions.


class UserRole {

    User user
    Role role

    //more stuff

}

class Role {

    String authority

    //more stuff

}

class User {

    //lots of stuff, but nothing that links back to the Role class or the UserRole class

}

Crudof’s answer worked for me after some alterations. Crudof pointed out that the package name UserRole does not follow Java package naming conventions. This is true, but if I remember right the Spring Security Core plugin automatically creates that package and the classes in it, so I didn’t mess with the name… But it has been a while since I did that, so I could be mistaken about it automatically naming the package.

<g:set var="desiredRole" value='${org.me.example.UserRole.Role.findByAuthority("ROLE_ADMIN")}' />
<g:select name="loggedBy.id" from="${org.me.example.UserRole.UserRole.findAllByRole(desiredRole).user}" optionKey="id" value=""  />
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:21:24+00:00Added an answer on May 24, 2026 at 6:21 pm
    1. Your package names are not conform to common java-standards: package names should/HAVE TO start with lower case character. Otherwise one is confused, that it might be a class (where UserRole is a nested class of UserRole).
    2. Basically your code snippet is fine (concept-wise). Note, that you cannot use double-quotes in double-quotes attribute values! I think this has stopped your progress. You can try the following:

      <g:set var="desiredRole" 
          value='${org.me.example.UserRole.findByAuthority("ROLE_ADMIN")}' />
      
      <g:select name="userSelect" 
          from="${org.me.example.UserRole.findAllByRole(desiredRole).user}" />
      

      Note that accessing the user-instances from the UserRole-instances is a groovy-sugar. See http://groovy.codehaus.org/Collections for a few examples.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code get's the currently logged in user, using the Spring Security Plugin (acegi):
Is it possible, using spring security plugin 0.5.3 with Grails 1.2.1, to authenticate a
I'm building a web application with Grails, using the Acegi/Spring Security plugin. I want
I'm developing a Grails (Version 1.3.3) Web-Application using the Grails Spring-Security Plugin, Spring-Security-Core-1.0.1 (which,
I'm using spring security, and I need to get the User domain object in
I have configured spring security core plugin using requestmap table inside the database.. Now
I am using spring security and have an admin jsp page for editing user
I have integrated spring security plugin with my grails application, which has hibernate as
I'm sure this is a fairly common situation. I'm using the Spring Security Core
I am using spring security and i am wondering how to change the default

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.