A session bean is created by a client and exists only for the duration of a single session. A session bean performs operations on behalf of the client such as reading, writing, or updating a database; however, session beans do not represent data to be stored in a database. Session beans can also be transactional; however, since they are not persistent, they cannot be recovered after a system crash.
Session beans can be stateless or can maintain conversational state across methods and transactions. The state describes the conversation between a session bean and its client. The EJB container manages this conversational state of a session bean and destroys the session bean when it is no longer needed.
A stateful session bean extends its client application and performs tasks on its behalf and maintains a state related to its client. This state maintains a conversation between the client and the stateful session bean. Methods within a stateful session bean can read and write data to and from this conversational state, which can be shared among other methods within that bean. A stateful session bean services only one client at a time.
Unlike entity beans, stateful session beans do not represent data to be stored in a database, and do not survive database or system crashes.
This type of session EJB has no internal state, which means it doesn't need to be passivated and can service multiple clients efficiently. Unlike a stateful session bean, a stateless session bean is not dedicated to one client.
Developing Enterprise JavaBeans
Copyright © 1997, 2004, Oracle. All rights reserved.