EJB programming & troubleshooting: Can I write a query like "select count(*) from tablename

  1.          Hi,

            Can I write a query like "select count(*) from tablename" in an entity bean with CMP.If not how can I get count (# records) in an efficient way.

  2. im not very sure but i think u can write a finder method that returns a collection and then try to┬┤get the length of the collection.
  3. You can write anything you want in a business method of A CMP - container does not care what you do there, just don't fiddle with things like create, remove, load etc.
  4. In weblogic u can use the weblogic query language(during the deployment of the bean) in the find method of the home interface .That is the best way to count to the no of records.
  5. you can write any valid sql statement but take care of syntax

    select Max("id") from "tablename" where "cl"=?1