A session bean represents a short session with the client program and may perform database read/write operations. A session bean may call JDBC by itself, or it may use entity bean to complete this call. In this case, the session bean is the customer of the Entity Bean. The domain of a session bean contains the session state and is short-lived. If the server or client program crashes, the Session Bean will be lost. This mode is usually used in database programming languages such as PL/SQL.
An entity bean represents the data in a database and the method that acts on the data. In the employee information table of a relational database, each row is represented by a bean. Entity beans are transactional and long-lived. Entity Bean exists as long as the data stays in the database. This mode can be easily used in relational databases, not just object databases.
Session beans can be stateful or stateless.
A stateful Session Bean contains the session status that represents the client program. The session state is the domain value of the Session Bean instance plus all objects referenced by these domain values. Stateful session beans does not represent data in a persistent data storage, but it can represent a client program to access and update data.
Stateless session beans are not used for any status information of a specific client program. They are usually used to provide server-side behavior that does not maintain any specific State. Stateless session beans requires fewer system resources. An example of a stateless Session Bean is a service object that provides a general service or a shared view that represents the stored data.