5 Replies Latest reply on Jun 29, 2004 5:58 AM by aloubyansky

    EJB-QL Aggregate functions 3.2.4

    mozheyko_d

      Yes !!!
      They have made it.

      LocalHome interface:

       ...
       public Collection findPaysSum( Timestamp time1, Timestamp time2) throws FinderException;
       ...
      

      ejb-jar.xml:
       ...
       <ejb-ql>
       [CDATA[
       SELECT SUM(p.summa) FROM pay p WHERE p.moment > ?1 and p.moment < ?2
       ]]
       </ejb-ql>
       ...
      


      Use this method:
       ...
       Iterator it = payHome.findPaysSum( Timestamp.valueOf( time1), Timestamp.valueOf( time2)).iterator();
       if( it.hasNext()){
       Object pk = ( ( EJBLocalObject)it.next()).getPrimaryKey();
       return ( Double)pk;
       }
       ...
      


      But if the result of SUM function is null, this method throws the Exception:
      javax.ejb.TransactionRolledbackLocalException: Attempt to get lock ref with a null object; CausedByException is: Attempt to get lock ref with a null object

      How it is possible to bypass it?

      Thanks