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 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 returns 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 java.util.Collection ...

Get Enterprise JavaBeans, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.