EJB.4.3 Session and Entity Objects


The Enterprise JavaBeans architecture defines two types of enterprise bean objects:

  • A session object

  • An entity object

EJB.4.3.1 Session Objects

A typical session object has the following characteristics:

  • Executes on behalf of a single client.

  • Can be transaction-aware.

  • Updates shared data in an underlying database.

  • Does not represent directly shared data in the database, although it may access and update such data.

  • Is relatively short-lived.

  • Is removed when the EJB container crashes. The client has to reestablish a new session object to continue computation.

A typical EJB container provides a scalable runtime environment to execute a large number of session objects concurrently.

Session beans are intended to be stateful. The EJB specification also defines a stateless session bean as a special case of a session bean. There are minor differences in the API between stateful (normal) session beans and stateless session beans.

EJB.4.3.2 Entity Objects

A typical entity object has the following characteristics:

  • Provides an object view of data in the database.

  • Allows shared access from multiple users.

  • Can be long-lived (lives as long as the data in the database).

  • The entity, its primary key, and its remote reference survive the crash of the EJB container. If the state of an entity was being updated by a transaction at the time the container crashed, the entity's state is automatically reset to the state of the last committed transaction. The crash is not fully transparent to the client ”the client may receive an exception if it calls an entity in a container that has experienced a crash.

A typical EJB container and server provide a scalable runtime environment for a large number of concurrently active entity objects.



Java 2 Platform, Enterprise Edition. Platform and Component Specifications
Java 2 Platform, Enterprise Edition: Platform and Component Specifications
ISBN: 0201704560
EAN: 2147483647
Year: 2000
Pages: 399

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net