Hello,

Currently I'm using named query which is written in orm.xml and is working fine.

  | Query query = em.createNamedQuery("selectAddresses");
  | query.setParameter("postcode", 50000);
  | query.getResultList();
  | 
  | <query>
  | select * from address where postcode=:postcode ORDER BY state ASC
  | </query>
  | 
Is it possible to dynamically change the "ORDER BY state ASC" to ascending or 
descending in java code, either through query.setParameter("", "") or any other 
methods?

I've tried the setParameter method, for example

  | <query>select * from address where postcode=:postcode ORDER BY state 
:ordering</query>
  | 
  | query.setParameter("ordering", "ASC") or query.setParameter("ordering", 
"DESC")
  | 
but the result didn't seem to be consistent.

Thanks in advance.
Steven

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3969960#3969960

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3969960
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to