1 Reply Latest reply on Aug 20, 2002 2:42 AM by Fusayuki Minamoto

    Entity Bean Finder methods

    Todd Gould Novice

      As I'm new to entity beans, I'm trying to clarify something in my understanding about the finder method(s) and their associated return types. I'm using the Account Bean example from Ed Roman's book in the following. My question concerns why the Bean implementation returns only the Primary Key, yet the Home interface(s) and the client see a fully populated Account Object. For example, the Home interfaces are as follows from Chapter 6 examples:

      In the Remote Home:

      public Account findByPrimaryKey( AccountPK key )
      throws FinderException, RemoteException;
      public Collection findByOwnerName( String name )
      throws FinderException, RemoteException;
      In the Local Home:

      public AccountLocal findByPrimaryKey( AccountPK key )
      throws FinderException;
      public Collection findByOwnerName( String name )
      throws FinderException;

      Signatures from the Bean Implementation:

      public AccountPK ejbFindByPrimaryKey( AccountPK key )
      throws FinderException
      public Collection ejbFindByOwnerName( String name )
      throws FinderException

      Since the Bean only returns the AccountPK (in the case of the ejbFindByPrimaryKey method), how does the client eventually see a fully populated Account or AcountLocal Object? The same question applies for the collection version as the ejbFindByOwnerName only returns a Collection of PKs - not full Account Objects?

      I assume that the EJBObject compiled by the container must be doing the conversion/population somehow. However, I did not see any calls to the ejbLoad method that would allow me to see how/when this is ocurring? I'm using JBoss 3.0 if this might be a container specific question.

      Can anyone help me to understand what's going on here and perhaps the rationale behind it?



        • 1. Re: Entity Bean Finder methods
          Fusayuki Minamoto Apprentice

          > However, I did not see any calls to the ejbLoad
          > method that would allow me to see how/when this is
          > ocurring?

          The ejbLoad is called when you access the bean.

          Finders return proxies of beans to clients.
          Invoking a method to a proxy on cilent side, the proxy invokes the ejb container on server side.
          Then one of the container interceptors may load the ejb record if necessary.

          You could see what's happening in the jboss server by adding next lines in the conf/log4j.conf:

          After executing your sample, see the log/server.log.
          You will see client-container interactions in detail.

          It would be helpful if your bean prints a mark so that you can easily find the place in the server log.

          public void ejbLoad() {
          System.out.println("********************** ejbLoad");