[jboss-user] [EJB 3.0] - Using a parameter as order by column
milestone
do-not-reply at jboss.com
Wed Mar 7 11:30:53 EST 2007
Hi all,
I am developing a Rich Client talking to my jboss server via Session Beans. Now within my Session Bean, I have the following Function:
| public List<Domaindata> getAllDomains(String orderByColumn)
| {
| Query query = em.createQuery("select d from Domaindata AS d ORDER BY :column");
| query.setParameter("column", orderByColumn);
|
| return query.getResultList();
| }
|
on the client side i am calling this function through its remote interface
| DomainRobotRemote robot = CommunicationHandler.getInstance().getDomainRobot();
| List<Domaindata> domains = robot.getAllDomains("name");
| for (Domaindata d : domains)
| {
| theNode.add(new DefaultMutableTreeNode(d.getName()));
| }
|
I can see the query translated by hibernate as
| 16:08:06,302 INFO [STDOUT] Hibernate: select ... borc.DOMAINDATA domaindata0_ order by ?
|
but the result list is not ordered.
If I explicitly order by a specific domain as in
| public List<Domaindata> getAllDomainsByName()
| {
| return em.createQuery("from Domaindata domain order by domain.name").getResultList();
| }
|
Everything is working fine. Isn't it possible to dynamically say what Column I want the Result list to be orderd by?
Any Help is highly appreciated.
Juergen
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4025856#4025856
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4025856
More information about the jboss-user
mailing list