The home interface has a method findByPrimaryKey(PrimaryKey).
This method takes a primary key object and returns the EJBObject reference to instance representing the entity object.
The client code uses the EJBObject reference to access the bean instance. The client code is as follows:
public Customer findByPrimaryKey(String primaryKey)
throws FinderException, RemoteException;
The home object grabs an instance from the pool and invokes the
ejbFindByPrimaryKey(PrimaryKey).
This method uses the primary key to find the entity object and synchronize it with the instance. This method returns the primary key of the newly found entity object to the container. The container creates the EJBObject and passes its reference back to the home object. The MouseOver below explains the code for the ejbFindByPrimaryKey():
There are other kinds of finder methods that can be used to locate one or more entity objects in the database. These are discussed in a later module.
Finding Entity Objects Quiz
Click the Quiz link below to review your understanding of creating and finding entity beans. Finding Entity Objects - Quiz
The next lesson examines the EJBObject for the entity bean.