Thanks for your reply.
But in my actual requirement, i am using the query as a NamedQuery. Since NamedQueries are precompiled and improves performance, we dont want to change that. My actual query is something like this......
Code:
@NamedQuery(name = "PRODUCTS_DETAIL1"
query = "SELECT T1 FROM ProductsDetail T1 ,"
+ " Customer T2 "
+ "WHERE T1.groupType=:grpType "
+ "AND T1.customerID = T2.customerID "
+ "AND T1.customer_ID =:customerID "
+ "ORDER BY T1.productID"
),
@NamedQuery(name = "PRODUCTS_DETAIL2"
query = "SELECT T1 FROM ProductsDetail T1 ,"
+ " Customer T2 "
+ "WHERE T1.groupType=:grpType "
+ "AND T1.customerID = T2.customerID "
+ "AND T1.customer_ID =:customerID "
+ "ORDER BY T1.productName"
),
@NamedQuery(name = "PRODUCTS_DETAIL3"
query = "SELECT T1 FROM ProductsDetail T1 ,"
+ " Customer T2 "
+ "WHERE T1.groupType=:grpType "
+ "AND T1.customerID = T2.customerID "
+ "AND T1.customer_ID =:customerID "
+ "ORDER BY T1.quantity"
),
If you see the above queries, only Order By clause is different, everything is same.
How to change the NamedQuery during runtime????