[3.1.4 + Hibernate4] DetachedCriteria throws error if more than one alias is created
- Dominant language
- Groovy
- Stars
- 2.9k
- Forks
- 975
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 92
Description
Having domains:
```
class Parent {
String name
static hasMany = [children: Child]
}
class Child {
String name
Related related
static belongsTo = [parent: Parent]
}
class Related {
String name
}
```
Following detached criteria could be created:
```
new DetachedCriteria(Parent).build {
createAlias 'children', 'c'
createAlias 'c.related', 'r'
isNotNull 'r.name'
}
```
But on second call to createAlias - IllegalArgumentException: Argument [c.related] is not an association is thrown. Exactly the same code works if standard criteria is used instead of DetachedCriteria.
Example project is here: https://github.com/droggo/GrailsSubqueries
Integration Spec to demo this problem: https://github.com/droggo/GrailsSubqueries/blob/master/src/integration-test/groovy/error/DetachedCriteriaAliasIntegrationSpec.groovy
Contributor guide
Research direction
Start with the linked GrailsSubqueries integration spec, src/integration-test/groovy/error/DetachedCriteriaAliasIntegrationSpec.groovy, and run it against the reported Grails 3.1.4/Hibernate4 setup. Trace the two createAlias calls in DetachedCriteria and compare them with standard criteria. Done means the nested alias example runs without the c.related association error and the integration spec passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100