order by problem
ongtw Dec 2, 2003 5:02 AMhi all,
i tried playing around with this order by thingy that you've been talking about here but to no avail. what i did is similar to the following:
in my ejb:
/**
* @ejb.interface-method
* @
*/
public abstract java.util.Collection ejbSelectGeneric(String jbossQL, Object[] args)
throws javax.ejb.FinderException;
/**
* @ejb:home-method
* tview-type="local"
**/
public java.util.Collection ejbHomeOrdersByCusid(java.lang.Integer cusid, java.lang.Integer filter, java.lang.String sortby)
throws javax.ejb.FinderException{
// generate JBossQL query
StringBuffer DynamicQl = new StringBuffer();
DynamicQl.append("SELECT OBJECT(g) ");
DynamicQl.append("FROM Job g ");
DynamicQl.append("WHERE g.cus_no = ?1 AND g.status = ?2");
DynamicQl.append(" ORDER BY g.");
DynamicQl.append(sortby);
Debug.print(DynamicQl.toString());
// pack arguments into an Object[]
Object[] args = new Object[2];
args[0]= cusid;
args[1]= filter;
//args[2]= sortby;
Debug.print("args[0]:"+args[0]);
Debug.print("args[1]:"+args[1]); return ejbSelectGeneric(DynamicQl.toString(), args);
}
in my session bean i have this:
/**
* @ejb.interface-method
* tview-type="remote"
**/
public java.util.Collection getAllOrders(java.lang.Integer cusid, java.lang.Integer filter, java.lang.String sortby){
try{
Debug.print("Entering getAllOrders");
JobHome = JobUtil.getLocalHome();
Job = JobHome.ordersByCusid(cusid,filter,sortby);
Debug.print("Leaving getAllOrders");
}catch(NamingException name){
Debug.print("ProcessOrder: userExists: NamingException occured in JobUtil.getLocalHome()");
return null;
}catch(javax.ejb.FinderException name2){
Debug.print("ProcessOrder: cannot locate method");
return null;
}
return Job;
}
I did add the following to the xml file as stated:
<query-method>
<method-name>ejbSelectGeneric</method-name>
<method-params>
<method-param>java.lang.String</method-param>
<method-param>java.lang.Object[]</method-param>
</method-params>
</query-method>
<dynamic-ql/>
now the problem is whenever it is calling this ejbSelect method, it returns a finderexception. it cannot locate the method. can anyone help me?