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.
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.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货