1 Reply Latest reply on Jan 26, 2003 5:14 PM by Juha Lindfors

    Loading a list of entity beans...

    Rajasekhar Atteri Newbie

      If I want to show the user a listing of all records in the database, should I use a finder method of EJB? Will this instantiate thousands of EJB's which would be inefficient, or will it just return a collection of primary keys, and only instantiate a bean when a specific instance is requested?

      In other words, should I use JDBC for retrieving huge lists and only get the bean when the user clicks on a particular item?
      Or is it safe to get the whole Collection using the home's finder method and assume the container is smart about the allocation of resources?

        • 1. Re: Loading a list of entity beans...
          Juha Lindfors Master

          The default behavior for the container is to fetch the primary keys from the database and create entity proxy per each key. The rest of the data fields will be loaded when you actually invoke a method on the entity proxy.

          Depending on your usage patterns, what is loaded on the finder call can be controlled in jbosscmp-jdbc.xml file of your bean. See Dain's CMP documentation for more information.