1 Reply Latest reply on Oct 23, 2004 10:23 PM by Joan Horta Tosas

    Max function error in ejb-ql

    ashishabrol Newbie

      Hi everyone,

      I am facing a problem retriveing the Maximum ID from a table called "Memo".

      In ejb-jar.xml file I have defined the query in the following manner-

      <ejb-ql><![CDATA[SELECT max(a.id) FROM Memo AS a]]></ejb-ql>

      and in the LocalHome interface the method has been declared as below -
      MemoLocal findMaxID ( ) throws FinderException;

      But when I call this findMaxID() function from my session bean in the following -

      public int findMaxIDInMemo()throws NamingException, FinderException
      MemoLocalHome memoLocalHome;
      MemoLocal memoLocal;

      int iRetVal = 0;
      memoLocalHome = this.getMemoLocalHome();
      memoLocal = memoLocalHome.findMaxID();
      iRetVal = Integer.parseInt(memoLocal.getId().toString());
      RetVal ++;
      } catch (Throwable e)

      return iRetVal;

      I get this error-

      javax.ejb.FinderException: Find failed: java.sql.SQLException: Got a java.lang.Long[cl=0, value=1]