An enterprise session bean executes on behalf of a single client. In a sense, the session bean represents the client in the EJB server. Session beans can maintain the client's state, which means they can retain information for the client. The classic example where a session bean might be used is a shopping cart for an individual shopping at an online store on the web. As the shopper selects items to put in the "cart," the session bean retains a list of the selected items. Session beans can be short-lived. Usually when the client ends the session, the bean is removed by the client. Session beans can be either stateful or stateless. Stateless beans don't maintain state for a particular client. Because they don't maintain state, stateless beans can be used to support multiple clients.
An entity bean provides an object view of data in a database. Usually the bean represents rows in a set of relational database tables. An entity bean usually serves more than one client. Unlike session beans, entity beans are considered to be long-lived. They maintain a persistent state, living as long as the data remains in the database, rather than as long as a particular client needs it. The container can manage the bean's persistence, or the bean can manage it itself. If the persistence is bean-managed, the bean developer must write code that includes calls to the database.