apache / apache/grails-intellij-plugin
Grails domain foreign entity generated ID field is incorrectly treated as a long, causing Inspection errors
- Dominant language
- Java
- Stars
- 17
- Forks
- 4
- Avg merge
- 5d 15h
- Merged PRs (30d)
- 4
Description
I am using UUIDs as the ID of my domain objects, each of them has a UUID id field directly in the class, rather than relying on a common trait which defines it (as it was picked up by IDEA as a Long in that case as well).
When I have a reference to another domain object, and use the generated referenceId getter, IDEA treats it as a Long and will give an inspection error if it's used where a UUID is expected.
Example:
User domain object has these fields:
UUID id
String username
Role domain object has these fields:
UUID id
String name
UserRole domain object has these fields
User user
Role role
If I do something like the following, I get an inspection warning when I call .put on the Map or .add on the list
```
Map> userIdsByRoleId = new HashMap>()
UserRole.list().each { UserRole userRole ->
List userIds = userIdsByRoleId.get(userRole.roleId)
if (userIds == null) {
userIds = new ArrayList()
userIdsByRoleId.put(userRole.roleId, userIds)
}
userIds.add(userRole.userId)
}
```
---
*Imported from [IDEA-177687](https://youtrack.jetbrains.com/issue/IDEA-177687) · Type: Bug · Votes: 0*
*Comments, attachments, dates and reporter are not part of the export — follow the link above for the full history.*
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue provides no repository file or test entry point. Reproduce the shown User, Role, and UserRole UUID case in IntelliJ, then locate the Grails support responsible for inferring generated referenceId types; done means the inspection recognizes userRole.roleId and userRole.userId as UUID values rather than Long.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy, java
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100