Using The generated BMP EJB Classes Code
This section starts by giving an overview of the generated code. The
subsequent sections start by explaining how to use classes.
To find out how to control the way the code is generated for EJB's, please
click here.
Database Table Columns Used
In order to make this section easier, a Person table is taken as an
example.
Note that the primary key is not used for update operations.
Finders
The following finders have been defined.
- findByPrimaryKey is always generated. The EJB specification states
that all BMP EJB's should have this method.
- findAll is an additional finder we have defined.
findAll
The find all method was defined as follows:
Finder has MaxRecords Parameter is checked. This means the
finder generated looks like this in the home interface:
/**
* Home interface finder.
* Finds 0 or more records
* @param theMaxRecords Maximum number of records retrieved from the database
* @throws FinderException Something went wrong in the finder code
* @throws RemoteException A system level error
* @return an enumeration of 0+ Person remote interface objects
*/
public Enumeration findAll(int theMaxRecords) throws RemoteException, FinderException;
EJB Files Generated
The wizard generates the following files:
- The remote interface. Person.java, is used by the client to represent an instance
of a bean. The interface includes methods to get and set bean properties.
The remote interface extends EJBObject, and so also has methods to get the
primary key, get the handle, and remove to the bean.
- The bean package, testDB is the name of the java package all generated
files should use.
- The implementation class PersonEJB.java.
Contained within are all the methods necessary to implement the EJB.
- The home interface PersonHome.java (bean factory), is used by the client to
create and find bean instances. This interface extends EJBHome, and so also
has methods to remove a bean instance.
- The key class is used to hold a bean's primary key valur. The key class is
a java type for simple keys. The wizard generates classes to represent a
composite key's values.
- Key class String is the class used to
represent the primary key. This is usually a Java type. Should the key be
composite, the wizard generates an appropriate primary key class.
- DAO key class PersonDAOKey.java; is used by the implementation class. This class is
the data access object for the bean's key. This class contains JDBC code to
find primary keys behind the scenes.
- DAO data class PersonDAOData.java is used to hold all of a bean's property values.
- DAO class PersonDAO.java, contains JDBC code to manage one bean instance:
findByPrimaryKey, store, create, remove.
- The manifest META-INF/ejb-jar.xml, is
generated as specified by the EJB 1.1 specification.
To generate a BMP EJB jar file, the java classes should be compiled and added
to a new jar file, along with the manifest file. See the java documentation for
information on creating jar files using the jar tool.
Copyright © 2002 J3
Limited, all rights reserved.