4 Replies Latest reply on Apr 22, 2002 3:21 PM by jmschust

    select count(*) from table

    lasterra

      How can I make this kind of select using CMP1.1??

      And with CMP2.0??

      Regards, Enrique.

        • 1. Re: select count(*) from table
          jmschust

          That's not really how CMP's work. Just make a BMP instead, it'll be small, and to be quite honest, there will be less lines of code than a CMP if you include descriptors.

          • 2. Re: select count(*) from table
            jmschust

            Oh, another option if you already have CMPs defined for that table is to create a Home method in the CMP. This can just be count incrementor for every load... it's in the 2.0 spec.

            • 3. Re: select count(*) from table
              lasterra

              i don't understand the second suggestion.
              Can you explain it better?

              Thank you very much.

              Regards, Enrique.

              • 4. Re: select count(*) from table
                jmschust

                A home method in a entity bean is a method in a object instance that is not associated with a specific primary key yet (or ever). Finder methods are like this.

                What you can do is create a singleton, accessable from a home method, that can do one of two things. One, simply keep a value that gets incremented by the entity on every create (therefore in essance counting the number of rows), or that uses some QL call against the beans to get the count (in which case you wouldn't need the singleton) which in essance would just be another finder method, with a select (*) in it.