In reality, many friends are misunderstood for two session beans. It is considered that there is a state that is always existed. Save the status after each call, and the next call works, and believes that stateless is instantified each time, no Keep user information. After careful analysis and use practice inspections, you will find that the truth is just right:
The essence of state and stateless session beans is their lifetime.
First explain the concept below to use - User: The user of session bean actually calls an instance of the class of EJB, even a method of this instance. Different instances of the same class are different users for Session Beans.
There is a stateful session bean: Each user has an instance of its own unique. In the user's survival period, Bean maintains the user's information, "State"; once the user is destroyed (the end or the end of the instance), the life of Bean Also end. That is, each user will initially get an initial bean.
Status Session Bean: Bean Once instantiated is added to the session pool, each user can be shared. Even if the user has done, the life of the bean is not necessarily over, which may still exist in the session pool for other users to call. Since there is no specific user, then the state of a certain user cannot be maintained, so there is no state Bean. But the stateful session bean is not a state, if it has its own property (variable), these variables will be affected by all users who call it, this is to pay attention in practical applications.