Select Methods 
A select method is similar to a finder method in the following ways: A select method can return a local or remote interface (or a collection of interfaces). 
A select method queries a database. 
The deployment descriptor specifies an EJB QL query for a select method. 
The entity bean class does not implement the select method. 
However, a select method differs significantly from a finder method: A select method can return a persistent field (or a collection thereof) of a related entity bean. A finder method can return only a local or remote interface (or a collection of interfaces). 
Since it is not exposed in any of the local or remote interfaces, a select method cannot be invoked by a client. It can be invoked only by the methods implemented within the entity bean class. A select method is usually invoked by a business method. 
A select method is defined in the entity bean class. For bean-managed persistence, a finder method is defined in the entity bean class, but for container-managed persistence it is not. 
The PlayerBean class defines these select methods: public abstract Collection ejbSelectLeagues(LocalPlayer player)
   throws FinderException;
public abstract Collection ejbSelectSports(LocalPlayer player)
   throws FinderException;
 The signature for a select method must follow these rules: The prefix of the method name must be ejbSelect. 
The access control modifier must be public. 
The method must be declared as abstract. 
The throws clause must include the javax.ejb.FinderException. These rules apply for a finder method: The name begins with find. 
The return type is the entity bean's local interface type, or a collection of those types. 
The throws clause contains the javax.ejb.FinderException. 
The findByPrimaryKey method must be defined. 

解决方案 »

  1.   

    在CMP2.0中,finder和ejbSelectXXX方法都是用来查找和引用其他BEAN实例(或BEAN实例集合),所不同的是finder在HOME接口中定义,在BEAN实现类中以抽象方法存在,也就是说finder可以暴露给客户来调用。而ejbSelectXXX不在HOME接口中做定义,而只在BEAN实现类中定义成抽象方法,也就是说ejbSelectXXX是BEAN在内部所调用的,它不能被客户通过HOME接口直接调用。另外,ejbSelectXXX是可以返回BEAN的CMP字段的。(非关系字段)