Count, Max, ...

Discussions

EJB programming & troubleshooting: Count, Max, ...

  1. Count, Max, ... (2 messages)

    Hi,

    With CMP entity beans, how can you do things like:

    SELECT COUNT(*) FROM PRODUCTS

    and

    SELECT MAX(salary) FROM EMPLOYEES

    I know I could write an ejbHome method that first calls a findAll() ejbFinder method, then calls size() on the returned collection to immitate a SELECT COUNT(*), or iterates through all elements of the collection to immitate a SELECT MAX(...), but both operation would be incredibly expensive compared to a true SQL call.

    Threaded Messages (2)

  2. Count, Max, ...[ Go to top ]

    Why does your home method have to finadAll()? It can make COUNT(*) SQL calls directly. For all intents and purposes, home methods in entity beans are the same as regular methods in stateless session beans.
  3. Count, Max, ...[ Go to top ]

    agree... sometime i think it's why we don't do all these extra SQL works in the *Home* rather than putting them into the session bean... i see it adding some extra work to do that..