This content has been marked as final.
Show 3 replies
-
1. Re: Using a parameter as order by column
wolfgangknauf Mar 7, 2007 11:36 AM (in response to milestone)Hi Jürgen,
that's not possible. You cannot use parameters to control ordering.
There are same posts in this forum regarding this problem, but there were no "brilliant" solutions.
In your case (you don't use named queries), you could simply add the order by column to your query:Query query = em.createQuery("select d from Domaindata AS d ORDER BY " + orderByColumn);
Hope this helps
Wolfgang -
2. Re: Using a parameter as order by column
milestone Mar 7, 2007 11:51 AM (in response to milestone)Hi Wolfgang,
although not really what I hoped for, because, at least from my point of view, this seemed to be how it should be done. At Last one never stops learning, and although not pretty, your solution works, and that makes me happy ;)
Kind regards
Juergen -
3. Re: Using a parameter as order by column
hanasakijiji Mar 8, 2007 12:51 PM (in response to milestone)do be careful of SQL injection if you are concatenating strings.