Chapter 8. Developing Entity Beans
Database Access for Container-Managed Persistence. In the Home interface, the finder methods must
adhere to the following rules:
They must be named
•
The return type must be the Enterprise Bean's component interface, or a collection thereof.
•
The exceptions defined in the
•
the matching
ejbFind
java.rmi.RemoteException
At least one of these methods is mandatory:
key value and returns the corresponding EJB object.
8.2.4. home Methods
Home methods are methods that the bean provider supplies for business logic that is not specific to an
Entity Bean instance.
The
clause of every home method on the remote home interface includes the
•
throws
java.rmi.RemoteException
Home methods implementation is provided by the bean developer in the bean implementation class
•
as public static methods named
name of the method in the home interface.
8.2.5. Home Interface Example
The Account Bean example, provided with the platform examples, is used to illustrate these concepts.
The state of an Entity Bean instance is stored in a relational database, where the following table should
exist, if CMP 1.1 is used:
create table ACCOUNT (ACCNO integer primary key,
CUSTOMER varchar(30),
BALANCE number(15,4));
public interface AccountHome extends EJBHome {
public Account create(int accno, String customer, double balance)
throws RemoteException, CreateException;
public Account findByPrimaryKey(Integer pk)
throws RemoteException, FinderException;
public Account findByNumber(int accno)
throws RemoteException, FinderException;
public Enumeration findLargeAccounts(double val)
throws RemoteException, FinderException;
}
(for example,
find method
throws
method, and must include
(the latter, only for a remote interface).
findByPrimaryKey
.
ejbHome METHOD_NAME (...)
findLargeAccounts
clause must include the exceptions defined for
javax.ejb.FinderException
, which takes as argument a primary
).
, where
METHOD_NAME
81
and
is the
Need help?
Do you have a question about the APPLICATION SERVER - JONAS and is the answer not in the manual?
Questions and answers