Discussions

EJB design: when will the entity bean be loaded ?

  1. when will the entity bean be loaded ? (3 messages)


    Will Weblogic(5.1) load the entity bean by calling
    ejbLoad() when ejbFindByPrimaryKey() is invoked or will it load the bean only when a method is invoked on the bean ?

    Please suggest.
    Thanks,
    Bhavesh
  2. When the entity beans are in the pool it does not have any entity bean database data loaded into it. These bean instances are used to service the finder methods.
    The ejbLoad() and ejbStore methods are called by the container when appropriate depending on how your transaction is defined.


    Madhavi
  3. I believe the ejbLoad() & ejbStore() methods will be called by the container whenever it wants to sync up the entity bean with the datasource. How often this is done is vendor specific. But in general, an ejbLoad() is done whenever an entity bean instance is pulled out from the instance pool to be associated with an EJBObject stub.

    The finder methods like ejbFindByPrimaryKey() are assigned by the container to the entity beans in the Pooled state rather than to the ones servicing client requests (Ready state).
  4. When you do a find by PrimaryKey the bean gets loaded with the full data.

    Supposing in this method if you set the class variables and again access through the get method, it gets loaded in ejbload(). Hope you got my point. As soon as the exceution of findbyPKey() is complete ejbpassivate() will be called.
    When you call a get method it will be returning null.Thats the reason you need to implement ejbload() which loads the bean once again. Hope you got it. You can go thru life cycle of an Entity Bean in (EJB O'Reilly Publications to get the right idea.)

    Ramki.