7.2.3 Entity beans

An entity bean represents persistent data. Most external clients access entity beans by using session beans, but it is possible for an external client to access an entity bean directly. The information contained in an entity bean is not associated with a session or with the handling of one client request or series of client requests. However, it is common for a client to make a succession of requests targeted at the same entity bean instance. It is also possible for more than one client to independently access the same entity bean instance within a short time interval. The state of an entity bean must therefore be kept consistent across multiple client requests.

For entity beans, the concept of a session is replaced by the concept of a transaction. An entity bean is instantiated in a container for the duration of the client transaction in which it participates. All subsequent accesses to that entity bean within the context of that transaction are performed against that instance of the bean in that particular container. The container needs to maintain state information only within the context of that transaction. The workload management service uses the concept of transaction affinity (Transaction affinity) to direct client requests. After an EJB server entity bean is selected, client requests are directed towards it for the duration of the transaction.

Between transactions, the state of the entity bean can be cached. The WebSphere V6.x EJB container supports Option A, Option B, and Option C caching:

Entity beans can participate in workload management as long as the server reloads the data into the bean at the start of each transaction, assuming that transactional affinity is in place. Guaranteed passivation at the end of each transaction is not a requirement for a bean to participate in workload management. Hence, Option B and Option C caching are both compatible with workload management, but Option A caching is not.

EJB caching options...

Option Activate at must be set to Load at must be set to
A Once Activation
B Once At start of transaction
C (default) At start of transaction At start of transaction

Summary of EJB types and WLM...

EJB types Component WLM-capable
Entity bean (Option A) Home Yes
CMP bean instance No
BMP bean instance No
Entity bean (Option B,C) Home Yes
CMP bean instance Yes
BMP bean instance Yes
Message-driven bean Bean instance Yes
Session Bean Home Yes
Stateless bean instance Yes
Stateful bean instance No


Next