user manual
104 BES Developer’s Guide
creditCardNumber, and expirationDate--then calls the create() method. This is
shown in the code sample below:
Cart cart;
{
String cardHolderName = "Jack B. Quick";
String creditCardNumber = "1234-5678-9012-3456";
Date expirationDate = new GregorianCalendar(2001, Calendar.JULY,
1).getTime();
cart = home.create(cardHolderName, creditCardNumber, expirationDate);
}
Session beans do not have finder methods.
Entity beans
A client obtains a reference to an entity object either through a find operation
or a create operation. Recall that an entity object represents some underlying
data stored in a database. Because the entity bean represents persistent data,
entity beans typically exist for quite a long time; certainly for much longer than
the client applications that call them. Thus, a client most often needs to find
the entity bean that represents the piece of persistent data of interest, rather
than creating a new entity object, which would create and store new data in
the underlying database.
A client uses a find operation to locate an existing entity object, such as a
specific row within a relational database table. That is, find operations locate
data entities that have previously been inserted into data storage. The data
may have been added to the data store by an entity bean or it may have been
added outside of the EJB context, such as directly from within the database
management system (DBMS). Or, in the case of legacy systems, the data may
have existed prior to the installation of the EJB container.
A client uses an entity bean object's create() method to create a new data
entity that will be stored in the underlying database. An entity bean's create()
method inserts the entity state into the database, initializing the entity's
variables according to the values in the create() method's parameters. A
create() method for an entity bean always returns the remote interface, but the
corresponding ejbCreate() method returns primary key of the entity instance.
Every entity bean instance must have a primary key that uniquely identifies it.
An entity bean instance can also have secondary keys that can be used to
locate a particular entity object.
Find methods and primary key class
The default find method for an entity bean is the findByPrimaryKey() method,
which locates the entity object using its primary key value. Its signature is as
follows:
<remote interface> findByPrimaryKey( <key type> primaryKey )
Every entity bean must implement a findByPrimaryKey() method. The primaryKey
parameter is a separate primary key class that is defined in the deployment
descriptor. The key type is the type for the primary key, and it must be a legal










