2 Replies Latest reply on Mar 18, 2004 4:08 PM by mkyaj

    EJB Pool

    mkyaj Newbie

      I am calling a findAll method that returns collection of entityA and using those entities one-by-one as
      Collection col = home.findAll();
      while(col has elements) { EntityA = (EntityA)col.next(); .... }
      If i have 100 records, then the JBOSSCMP is creating 100 instances in the EntityA pool. so the following code will be repeated 100 times
      In the setEntityContext of EntityA
      In the ejbActivate of EntityA
      In the ejbLoad of EntityA
      Instead of creating those many instances and setting the entitycontext(which is costly i feel), can i reuse the same instances from entity pool?
      Please throw me some hints.


        • 1. Re: EJB Pool
          Bill Burke Master

          entity instance is not created until you actually invoke a method on the entity.

          JBoss 3.2.2RC1 and higher uses a pool and ejbLoad must be called.

          If you're not using caching (commit A) there are prefetch strategies you can use like on-find to speed performance.

          • 2. Re: EJB Pool
            mkyaj Newbie

            Hi Bill,

            Thank you for the response.
            I m using the on-load strategy. But my problem is instead of creating 100 instances in the EJBPool of that entity, can we create only some 10 instances and use the same for loading all entities.

            So that i can reduce the setEntityContext() operation for all the entities. I think the setEntityContext() is more costly than ejbActivate().

            Thank you.