sdelamo opened a new issue, #14516:
URL: https://github.com/apache/grails-core/issues/14516
Given these domain classes:
```groovy
class Role {
String authority
}
class User {
String username
}
class UserRole implements Serializable {
private static final long serialVersionUID = 1
User user
Role role
static mapping = {
id composite: ['user', 'role']
version false
}
}
```
and this query:
```groovy
@ReadOnly
List<Long> findAllRoleIdsByUser(Long userId) {
def c = UserRole.createCriteria()
c.list {
projections {
role {
property('id')
}
}
user {
eq('id', userId)
}
} as List<Long>
}
```
With Grails 3.3.11 and GORM 6.1.12.RELEASE it works.
For Grails 4.0.2 and GORM 7.0.2, it fails with:
`Caused by: java.lang.IllegalArgumentException: Unable to locate Attribute
with the the given name [role] on this ManagedType [example.grails.UserRole]`
It seems to be related with the composite key of `UserRole` Removing that
key gets rids of the error.
### Environment Information
- **Operating System**: MacOS
- **Grails Version:** 4.0.2
- **JDK Version:** 1.8
- **Container Version (If Applicable):** TODO
### Example Application
https://github.com/grails-core-issues-forks/grails-core-issue-11505
Steps to reproduce with the example app
*Grails 3*
```
cd grailsthree;
./gradlew bootRun
curl localhost:8080/home
{"ids":[1,2]}
```
*Grails 4*
```
cd grailsfour;
./gradlew bootRun
curl localhost:8080/home
Unable to locate Attribute with the the given name [role] on this
ManagedType [example.grails.UserRole]. Stacktrace follows:
...
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]