2 Replies Latest reply on Jan 27, 2003 6:36 AM by adrian.brock

    Regarding creation of Entity Bean instance

    seemanto

      When i call the findByPrimaryKey() method on the home object, it is seen that the constructor and setEntityContext() method of the corresponding BMP entity bean are called.

      Then i use the remote object returned by the call to findByPrimaryKey() to invoke bean's business method, what happens is that the constructor and setEntityContext() is called and then ejbActivate() and ejbLoad().

      My question is why is the container creating a new instance again when it's first business method is called. Isn't the container supposed to use the same instance that was created and sent to the pool while processing findByPrimaryKey(). Is this behavior conatiner dependent ? I am using jboss 3.04.

        • 1. Re: Regarding creation of Entity Bean instance
          pranav

          Yessss...you are right. The CONTAINER decided when to create a new bean and when to get one from the pool...

          Cheers

          > When i call the findByPrimaryKey() method on the home
          > object, it is seen that the constructor and
          > setEntityContext() method of the corresponding BMP
          > entity bean are called.
          >
          > Then i use the remote object returned by the call to
          > findByPrimaryKey() to invoke bean's business method,
          > what happens is that the constructor and
          > setEntityContext() is called and then ejbActivate()
          > and ejbLoad().
          >
          > My question is why is the container creating a new
          > instance again when it's first business method is
          > called. Isn't the container supposed to use the same
          > instance that was created and sent to the pool while
          > processing findByPrimaryKey(). Is this behavior
          > conatiner dependent ? I am using jboss 3.04.

          • 2. Re: Regarding creation of Entity Bean instance

            The first invocation is against the home interface,
            it is not associated with any data. It just generates
            a proxy object that can be used to access the
            real bean. This invocation is stateless.

            When you use the proxy, it will create real bean
            with a primary key and data. You might never do
            this if you are just checking for existance.

            I don't know why it doesn't return the bean used
            in the home invocation to the pool. There
            is a comment in the code saying the author chose
            not do this, but it doesn't say why?

            Regards,
            Adrian