Hibernate Panache sorting not working with Named Query
See original GitHub issueDescribe the bug
Sorting not working with Named Query
@Entity
@NamedQueries({
@NamedQuery(name = "countFruit",
query = "FROM Fruit")
})
public class Fruit extends PanacheEntity {
@Column(length = 40, unique = true)
public String name;
public static List<Fruit> listSortedFruitsByNamedQuery() {
return list("#countFruit", Sort.by("name").ascending(), new HashMap<>()); // Not sorting
}
public static List<Fruit> listSortedFruits() {
return list("FROM Fruit", Sort.by("name").ascending(), new HashMap<>()); //Sorting is done
}
}
Expected behavior
find, list and stream functions should support sorting for named queries also.
Actual behavior
No errors, but the result list is not sorted if named query is used
How to Reproduce?
No response
Output of uname -a
or ver
No response
Output of java -version
openjdk version “11.0.11”
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.3.0.FINAL
Build tool (ie. output of mvnw --version
or gradlew --version
)
Apache Maven 3.6.3
Additional information
Possible related issue: https://github.com/quarkusio/quarkus/issues/20758
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (8 by maintainers)
Top Results From Across the Web
Simplified Hibernate ORM with Panache - Quarkus
Named queries can only be defined inside your JPA entity classes (being the Panache entity class, or the repository parameterized type), or on...
Read more >Named query for entity that does not associate with a specific ...
In the project I'm working on, it's around 5 JOIN tables to retrieve the information I'm looking for. table_b is purely a mapping...
Read more >Sorting with Hibernate - Baeldung
The default sort order direction is ascending. This is why the order condition, asc, is not included in the generated SQL query. 2.1....
Read more >Data Persistence with Quarkus and Hibernate Panache
So, you should have the following dependencies in your project. <dependencyManagement> <dependencies> <dependency> <groupId>io.quarkus</groupId> ...
Read more >A Qute Way to Visualise Data with Panache - Antonio's Blog
One of these famous frameworks is Hibernate which implements the JPA specification. Hibernate makes mapping and querying Java objects easy.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Or even better, we should throw an exception instead of silently ignoring when someone tries to sort and we cannot apply the sort.
OK then, I’ll implement an IllegalArgumentException when using named query and sort