Order by more than one property in criteria builder's params
- Dominant language
- Groovy
- Stars
- 2.9k
- Forks
- 975
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 92
Description
Sort parmeter in param map for Criteria builder doesn't work the same way as in Dynamic Finders. In dynamic finder we could do this:
```
Author.findAllByNameLike("A%", [sort: [name: "desc", id: "asc"]])
```
If we try to do the same for Criteria builder or with Detached Criteria:
```
Author.createCriteria().list(sort: [name: "desc", id: "asc"]) {
like 'name', "A%"
}
```
The ClassCastException will be thrown:
```
java.util.LinkedHashMap cannot be cast to java.lang.String. Stacktrace follows:
Message: java.util.LinkedHashMap cannot be cast to java.lang.String
Line | Method
->> 1615 | invokeMethod in org.grails.orm.hibernate.query.AbstractHibernateCriteriaBuilder
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
```
Contributor guide
Research direction
Start at line 1615 of org.grails.orm.hibernate.query.AbstractHibernateCriteriaBuilder and reproduce the ClassCastException with the Criteria builder example in the issue. Compare the parameter handling with the Dynamic Finder behavior; done means Criteria and Detached Criteria accept multiple sort properties with the shown ordering.
Written by the indexing model from the issue text.
Assessment
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100