Problem in finder method

Discussions

EJB programming & troubleshooting: Problem in finder method

  1. Problem in finder method (5 messages)

    hi,

    I am deploying a BMP entity bean in weblogic 5.1 oracle 8i databse as backend. This entity bean is called in session bean.
    I have define a Findermethod in Home Interface( say findByUserName)and implemented it in Bean in ejbFindByUserName. also there are 4 remote methods in bean( say eg. getUserName() , getPassword() etc). in finder method i select values from database and set it into fields of entity beans which will be returned when the remote methods will be called.

    Now in session bean after lookup the Entity home interface i call Home's ejbFindByUserName method to get a remote reference of bean. upto this it is ok. after that when i call remote method getUserName(), getPassword() the bean return null. i diagnose the problem and came to know that before calling remote methods the entity bean's unsetEntityContext is called and it goes to Pool. when i call remote method it is again comes from pool and all the filed which i set earlier get null.

    so tell me what i should do to get the values which i set in finder methods return from remote methods.

    if any have solution pl. mail me at sudhirk76 at rediffmail dot com

    This is urgent i have to meet deadlines.

    sudhir.


    Threaded Messages (5)

  2. Problem in finder method[ Go to top ]

    After you have called the FinderMethod, you will only have obtained the primary key. You'll then have to do a find by primary key to get the remote interface.

    Cheers,
    Rick
  3. Problem in finder method[ Go to top ]

    After you have called the FinderMethod, you will only have obtained the primary key. You'll then have to do a find by primary key to get the remote interface.

    Cheers,
    Rick

    thanks rick,
    But i can not understand where i have to call findbyPrimaryKey Method. on client or on entity bean's finder method.


    sudhir




  4. Problem in finder method[ Go to top ]

    thanks rick,
    But i can not understand where i have to call findbyPrimaryKey Method. on client or on entity bean's finder method.


    sudhir




  5. Problem in finder method[ Go to top ]

    Firstly hold the context of the entity bean in your bean.
    Next, make sure that your finder methods returns either a PK or a collection of PK. Then in your ejbLoad(), get the PK from the context and use it to populate the fields.
  6. Problem in finder method[ Go to top ]

    For clearancy. If you want to make only one select (in the finder) and not two as it is mentioned in the theory (in the ejbLoad too), you must store the values in a primary key object, which serves as a data wrapper in the finder method. Then in the ejbLoad, you can populate the variables directly without another select by using the primary key class wrapper, which you can get from entity context. So you have to set the entity context too as sanjib mentioned.

    Michael