This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I'm working on an application where I'd like to dynamically determine whether the sorting returned during an HQL query is in descending or ascending order.
When trying to do this using a named query, I get errors during deployment. Here's an example of the code from the domain object:
In the DAO (using Spring), I call the query using a statement (eg.):
This doesn't work. I've even tried adding a case statement in the domain object:
Is there a way to dynamically set whether the results are in ascending or descending order or will I have to create two separate named queries for this (i.e. listcontacts_bytype_desc & listcontacts_bytype_asc)? (Or do something much simpler that I'm not thinking of).
I have come across something else, however, after further testing, it appears that I'm also not getting the "order" parameter set during my query either. Is it not possible to set the "order" parameter dynamically using ?