1 Reply Latest reply on Feb 22, 2002 11:41 AM by armint

    Entity EJB - unsetEntityContext Question

    jcozens

      Hi, I'm a little confused about when the unsetEntityContext method is invoked, could anyone help?

      In an Entity EJB when does the callback method unsetEntityContext get called? Is it:

      1) when an entity instance is disassociated from its EJB Object because the entity instance is passivated or 'removed'. The EJB Object is then returned to the EJB Object Pool.

      2) Or, when an EJB Object is destroyed and removed from the EJB Object Pool?


      I guess it's a question of: is the 'unsetEntityContext' method part of the life cycle of the EJB Object or the bean instance?

      I hope I've been clear. Thanks for your help

        • 1. Re: Entity EJB - unsetEntityContext Question
          armint

          This is a good question because it's important to understand the lifecycle of ejbs in order to use them correctly. Be careful using the word EJB Object because EJBObject is the remote interface for an EntityBean instance. It is the EntityBean instances that are pooled and not EJBObjects. unSetEntityContext() is called before a pooled EntityBean instance (i.e. without identity) is removed from the pool.

          The ejb spec at java.sun.com has sequence diagrams that describe this behavior. It is definitely worthwhile to take a look at. Also, Oreilly's ejb book has got some nice diagrams in the appendices.