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
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 ;)
do be careful of SQL injection if you are concatenating strings.