If you take a look at the default implementation of User#getAuthorities
you will note that the property is itself implemented with a dynamic finder call:
UserRole.findAllByUser(this).collect { it.role } as Set
Therefore you can not refer to authorities
in the HSQL query, but you can query users with a specific role over the UserRole
association domain class in multiple ways:
def users = UserRole.withCriteria {
role{
eq 'authority', 'ROLE_SOMETHING'
}
projections{
property 'user'
}
}
or
def users = UserRole.findAllByRole(domainRole)?.user