![Red Hat Application Server Manual Download Page 89](http://html.mh-extra.com/html/red-hat/application-server/application-server_manual_1427406089.webp)
Chapter 8. Developing Entity Beans
81
Database Access for Container-Managed Persistence
. In the Home interface, the finder methods must
adhere to the following rules:
•
They must be named
find
"
method
#
(for example,
findLargeAccounts
).
•
The return type must be the Enterprise Bean’s component interface, or a collection thereof.
•
The exceptions defined in the
throws
clause must include the exceptions defined for
the matching
ejbFind
method, and must include
javax.ejb.FinderException
and
java.rmi.RemoteException
(the latter, only for a remote interface).
At least one of these methods is mandatory:
findByPrimaryKey
, which takes as argument a primary
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
throws
clause of every home method on the remote home interface includes the
java.rmi.RemoteException
.
•
Home methods implementation is provided by the bean developer in the bean implementation class
as public static methods named
ejbHome
"
METHOD_NAME
#
(...)
, where
"
METHOD_NAME
#
is the
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;
}
Summary of Contents for Application Server
Page 1: ...Red Hat Application Server JOnAS User Guide ...
Page 8: ......
Page 22: ...14 Chapter 1 Java Open Application Server JOnAS a J2EE Platform ...
Page 58: ...50 Chapter 3 JOnAS Configuration ...
Page 66: ...58 Chapter 5 JOnAS Class Loader Hierarchy ...
Page 78: ...70 Chapter 6 JOnAS Command Reference ...
Page 80: ......
Page 86: ...78 Chapter 7 Developing Session Beans ...
Page 136: ...128 Chapter 9 Developing Message Driven Beans ...
Page 142: ...134 Chapter 10 Defining the Deployment Descriptor ...
Page 148: ...140 Chapter 11 Transactional Behavior of EJB Applications ...
Page 158: ...150 Chapter 14 EJB Packaging ...
Page 162: ...154 Chapter 15 Application Deployment and Installation Guide ...
Page 164: ......
Page 176: ...168 Chapter 18 WAR Packaging ...
Page 178: ......
Page 184: ...176 Chapter 20 Defining the Client Deployment Descriptor ...
Page 186: ...178 Chapter 21 Client Packaging ...
Page 188: ......
Page 192: ...184 Chapter 23 EAR Packaging ...
Page 194: ......
Page 200: ...192 Chapter 24 JOnAS Services ...
Page 204: ...196 Chapter 25 JOnAS and the Connector Architecture ...
Page 222: ...214 Chapter 27 Ant EJB Tasks Using EJB JAR ...
Page 234: ...226 Chapter 29 Web Services with JOnAS ...
Page 236: ......
Page 260: ...252 Chapter 34 How to use Axis in JOnAS ...
Page 270: ...262 Chapter 36 Web Service Interoperability between JOnAS and BEA WebLogic ...
Page 296: ......