1 Reply Latest reply on May 28, 2003 9:22 AM by chriskrn1

    Aggregate functions (COUNT, MAX, etc.) do not work. Why?

    btud

      Hello!

      I have the following problem:

      I tried to make a select method which returns me the total number of rows.

      The EJB-QL looked like this:

      "SELECT COUNT(t) FROM Transaction t"

      When deployed jBoss throws a ParseError (something like
      "COUNT encountered when
      OBJECT,
      DISTINCT,
      <..._PATH>,
      <..._PATH>,
      .....,
      expected"

      The same thing happens with other aggregate functions (I tried with MAX also).

      I was forced to implement a separate method which acceses the database directly through JDBC (not recommended when using CMP though).

      What can be the reason for this and is there a way of dealing with it, without writing JDBC code inside the bean?

      Thanks,

      Bogdan.

        • 1. Re: Aggregate functions (COUNT, MAX, etc.) do not work. Why?
          chriskrn1

          Hi Bogdan

          The current EJB2.0 spec does not support the aggregate functions you mention, and thus you have no choice but to use JDBC or to use basic EJB-QL (and then use java to do what you require).

          To my knowledge, the latest spec EJB2.1 (which is in public draft final), does support these aggregate functions.

          Regards
          Chris