2 Replies Latest reply on Dec 3, 2003 6:59 AM by Darran Lofthouse

    order by problem

    ongtw Newbie

      hi 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?

        • 1. Re: order by problem
          ongtw Newbie

          i found the errors and am able to use it now.

          however when i tried to get the data out from the collection that it returns, it gave me the following errors:

          java.lang.NullPointerException
          at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:38)
          at $Proxy2.setCloseby(Unknown Source)
          at sg.com.studiotech.test.ProcessOrderTest.testBean(ProcessOrderTest.java:63)
          at sg.com.studiotech.test.ProcessOrderTest.main(ProcessOrderTest.java:83)
          Exception in thread "main"

          this error occurs when i tried to use the get method to get the data from this object. Does anyone know why this is happening?

          Any help will be appreciated.

          • 2. Re: order by problem
            Darran Lofthouse Master

            Where is your client, is it in the same JVM or is it remote?