I have several NamedQuery , and I would like to be able to sort by field for the object dynamically, without having to create a unique NamedQuery for each field that I want to sort. For example:
I have a MyObject with fields 'a', 'b', and 'c'. My basic query is " SELECT DISTINCT o FROM MyObject o ", but I would like to add an ORDER BY to my query. Ideally, I could do something like named parameters, where my query would look like this:
SELECT DISTINCT o FROM MyObject o ORDER BY :order
Then I have to specify the field (a, b, c) that I want to sort. Is there a way to do this using Seam / Hibernate / JPA? Is there a better strategy to solve this problem?
sorting hibernate jpa seam
Shadowman
source share