Stateful Session Bean vs Stateless Session Bean
In EJB3, we have two kinds of session beans: Stateful and Stateless. In which case do we have to use the Stateful beans? How 开发者_Go百科does EJB3 manage the session of the stateful session bean? Can we access the session-scoped value of this session bean? And when there are many users access to our application that use stateful session bean, how can the performance of our system be affected?
You should only use stateful session beans if you need to keep state between calls. (e.g a shopping cart that accumulates items) Stateless session beans can be pooled and is therefore more effective.
You should always try to keep things stateless, as this is more scalable.
精彩评论