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

    EJB-QL Aggregate functions 3.2.4

    Dmitry Mozheyko Novice

      Yes !!!
      They have made it.

      LocalHome interface:

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

       SELECT SUM(p.summa) FROM pay p WHERE p.moment > ?1 and p.moment < ?2

      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?