-
15. Re: New EJB-QL compiler (ORDER BY and DynamicQL)
liuqiang_home Sep 26, 2002 7:45 PM (in response to dsundstrom)Hi! I am using the dynamic-QL plus Order By, I want to do the following:
SELECT OBJECT(g) FROM UserInfo g ORDER BY ?1
I pass the argument as:
Object[] args= new Object[1];
args[0]= "g." + Order; //Order is Column name I pass in
But I got the following error message:
[junit] There was 1 error:
[junit] 1) testIVSSDataLayer_none(com.numeritech.ivss.dataLayer.ivstest)
[junit] javax.ejb.FinderException: Error compiling ejbql: org.jboss.ejb.plugins.cmp.ejbql.ParseE
tion: Encountered "1" at line 1, column 44.
[junit] Was expecting one of:
[junit] <NUMERIC_VALUED_PATH> ...
[junit] <STRING_VALUED_PATH> ...
[junit] <DATETIME_VALUED_PATH> ...
[junit]
[junit] at org.jboss.ejb.plugins.cmp.jdbc.JDBCDynamicQLQuery.execute(JDBCDynamicQLQuery.java
[junit] at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCSelectorBridge.execute(JDBCSelectorBrid
ava:64)
[junit] at org.jboss.ejb.plugins.cmp.bridge.EntityBridgeInvocationHandler.invoke(EntityBridg
ocationHandler.java:95)
[junit] at org.jboss.proxy.compiler.Runtime.invoke(Runtime.java:59)
_______________________________
it seems Dynamic-QL doesnot support this, am I right? or I did something wrong.
Thanks for reply ! -
16. Re: New EJB-QL compiler (ORDER BY and DynamicQL)
bleupen Sep 27, 2002 10:04 AM (in response to dsundstrom)if you are using dynamic-ql, then why do you need to use ?1 at all?
b -
17. Re: New EJB-QL compiler (ORDER BY and DynamicQL)
ongtw Dec 2, 2003 5:01 AM (in response to dsundstrom)dsunstorm,
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?