The following sections give an overview of enterprise beans. Enterprise beans are discussed in detail in Chapter 5 . 2.1.3.1 Session Beans A session bean is created to provide some service on behalf of a client and usually exists only for the duration of a single client-server session. A session bean performs operations such as calculations or accessing a database for the client. While a session bean may be transactional, it is not recoverable should its container crash.
Session beans can be stateless or can maintain conversational state across methods and transactions.
If they do maintain state, the EJB container manages this state if the object must be removed from memory. However, the session bean object itself must manage its own persistent data. An entity bean can manage its own persistence or it can delegate this function to its container. An entity bean can live as long as the data it represents. An entity bean is identified by a primary key.