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

  • SEARCH
  • Home
  • 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 8663049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:53:11+00:00 2026-06-12T16:53:11+00:00

I would like to create the following statement in Grails with HibernateCriteriaBuilder : SELECT

  • 0

I would like to create the following statement in Grails with HibernateCriteriaBuilder:

SELECT * FROM person p 
  JOIN person_authority pa ON p.id=pa.person_id 
  JOIN authority a ON pa.authority_id=a.id 
  WHERE a.authority IN ('ROLE_ADMIN');

person_authority is join table.

Update:

My Person class is:

class Person {

transient springSecurityService

Date dateCreated
Date lastLogin

String username
String password
String email;
boolean enabled
boolean accountExpired
boolean accountLocked
boolean passwordExpired

static constraints = {
    username blank: false, unique: true
    email blank:false, unique: true, email: true
    password blank: false
    lastLogin nullable:true
}

static mapping = {
    hasMany authority:Authority;
    password column: '`password`'
}

//Set<Authority> getAuthorities() {
//  PersonAuthority.findAllByPerson(this).collect { it.authority } as Set
//}

def beforeInsert() {
    encodePassword()
}

def beforeUpdate() {
    if (isDirty('password')) {
        encodePassword()
    }
}

protected void encodePassword() {
    password = springSecurityService.encodePassword(password)
}

public static def query(Map params = [:]){

    def rows = withCriteria(max:params.max,offset:params.offset){
        if(params.authorities){
            authorities{
                'in'('authority', params.authorities)
            }
        }
        order(params.column?:"id",params.order?:"asc")
        if(params.id){
            idEq (params.id as Long);
        }
        if(params.username){
            ilike "username","%"+params.username+"%"
        }
        if(params.email){
            ilike "email","%"+params.email+"%"
        }
        if(params.accountLocked){
            eq "accountLocked",Boolean.valueOf(params.accountLocked)
        }
        if(params.enabled){
            eq "enabled",Boolean.valueOf(params.enabled)
        }
        if(params.passwordExpired){
            eq "passwordExpired",Boolean.valueOf(params.passwordExpired)
        }
    }
    return rows;
}
}

Criteria I want to build is in method query. When I try to execute it I get groovy.lang.MissingMethodException: No signature of method: grails.orm.HibernateCriteriaBuilder.authorities() is applicable for argument types ...

  • 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-06-12T16:53:13+00:00Added an answer on June 12, 2026 at 4:53 pm

    It depends on how exactly you’ve defined association, but will look like:

    Person.withCriteria {
        authorities {
            'in'('authority', 'ROLE_ADMIN')
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to create a query that returns rows in the following format:
i have the following problem: i would like to create a footer. that footer
I have the following actor for which I would like to create unit tests
I would like to create a LINQ query which results in the following SQL
I have a SELECT statement which I would like to optimize. The mysql -
I'm having trouble converting the following SQL-statement to LINQ-to-entities: SELECT l.* FROM locations l
i would like create a array of structure which have a dynamic array :
I would like to create this shape using just css. I am pretty sure
I would like to create a c++ type that mimic the build-in type exactly.
I would like to create a json object to send as a post array,

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.