![Red Hat Application Server Manual Download Page 88](http://html.mh-extra.com/html/red-hat/application-server/application-server_manual_1427406088.webp)
80
Chapter 8. Developing Entity Beans
•
Bean-Managed Persistence
: the bean provider writes the database access operations (JDBC code)
in the methods of the enterprise bean that are specified for data creation, load, store, retrieval, and
remove operations (
ejbCreate
,
ejbLoad
,
ejbStore
,
ejbFind
...,
ejbRemove
).
Currently, the platform handles persistence in relational storage systems through the JDBC interface.
For both container-managed and bean-managed persistence, JDBC connections are obtained from an
object provided at the EJB server level, the
DataSource
. The DataSource interface is defined in the
JDBC 2.0 standard extensions (see http://java.sun.com/products/jdbc/). A DataSource object identifies
a database and a means to access it via JDBC (a JDBC driver). An EJB server may propose access to
several databases and thus provides the corresponding DataSource objects. DataSources are described
in more detail in Chapter 4
Configuring JDBC DataSources
.
8.2. The Home Interface
In addition to “home business methods,” the Home interface is used by any client application to cre-
ate, remove, and retrieve instances of the Entity Bean. The bean provider needs to provide only the
desired interface; the container will automatically provide the implementation. If it is remote, the in-
terface must extend the
javax.ejb.EJBHome
interface; if it is local, the interface must extend the
javax.ejb.EJBLocalHome
interface. The methods of a remote home interface must follow the rules
for Java RMI. The signatures of the
create
and
find
... methods should match the signatures of the
ejbCreate
and
ejbFind
... methods that will be provided later in the Enterprise Bean implementa-
tion class (the same number and types of arguments, but different return types).
8.2.1. create Methods
•
The return type is the Enterprise Bean’s component interface.
•
The exceptions defined in the
throws
clause must include the exceptions defined for the
ejbCreate and ejbPostCreate methods, and must include
javax.ejb.CreateException
and
java.rmi.RemoteException
(the latter is only for a remote interface).
8.2.2. remove Methods
•
The interfaces for these methods must not be defined—they are inherited from
EJBHome
or
EJBLocalHome
.
•
The method is
void remove
, taking as an argument the primary key object or the handle (for a
remote interface).
•
The exceptions defined in the throws clause should be
javax.ejb.RemoveException
and
java.rmi.RemoteException
for a remote interface.
•
The exceptions defined in the
throws
clause should be
javax.ejb.RemoveException
and
java.ejb.EJBException
for a local interface.
8.2.3. finder Methods
Finder methods are used to search for an EJB object or a collection of EJB objects. The arguments
of the method are used by the Entity Bean implementation to locate the requested entity objects.
For bean-managed persistence, the bean provider is responsible for developing the corresponding
ejbFinder methods in the bean implementation. For container-managed persistence, the bean provider
does not write these methods; they are generated at deployment time by the platform tools; the de-
scription of the method is provided in the deployment descriptor, as defined in Section 8.7
Configuring
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: ......