O'Reilly logo

Enterprise JavaBeans, Fourth Edition by Richard Monson-Haefel, Bill Burke, Sacha Labourey

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The ejbFind( ) Methods

In bean-managed persistence, the find methods in the remote or local home interface must match the ejbFind( ) methods in the actual bean class. In other words, for each method named find< SUFFIX >( ) in a home interface, there must be a corresponding ejbFind< SUFFIX >( ) method in the entity bean class with the same arguments and application exceptions. When a find method is invoked on an EJB home, the container delegates the find( ) method to a corresponding ejbFind( ) method on the bean instance. The bean-managed entity is responsible for locating records that match the find requests. There are two find methods in ShipHomeRemote:

public interface ShipHomeRemote extends javax.ejb.EJBHome {

    public ShipRemote findByPrimaryKey(Integer primaryKey) 
        throws FinderException, RemoteException;
    public Collection findByCapacity(int capacity) 
        throws FinderException, RemoteException;
}

Here are the signatures of the corresponding ejbFind( ) methods in the ShipBean:

public class ShipBean implements javax.ejb.EntityBean {

    public Integer ejbFindByPrimaryKey(Integer primaryKey) 
        throws FinderException {}
    public Collection ejbFindByCapacity(int capacity) 
        throws FinderException {}
}

Aside from the names, there’s a significant difference between these two groups of methods. The find methods in the home interface return either an EJB object implementing the bean’s remote interface—in this case, ShipRemote--or a collection of EJB objects in the form of a java.util.Enumeration or ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required