In this post i’ve explained some of the differences between session bean and entity bean.
Session Beans
– Session Beans represent a process or flow.
– Each session bean is associated with one EJB client at time.
(Session Beans are threadsafe)
– Session bean have types stateless and stateful. Stateless beans don’t maintain states while stateful bean does maintain state. Stateless beans can be easily reused by multiple clients rather than destroyed and recreated per client. Stateful beans can’t be reused by multiple clients and only one instance per client is allowed which makes them thread safe.
– Session beans don’t survive in middleware system shutdown. That means they’re not persistent.
Entity Beans
– Entity bean represent row in a database.
– Each entity bean is associated with more than one client at time.
– Entity bean have two types: CMP (Container managed persistence) and BMP (Bean managed persistence)
– Entity bean do survive in system shutdown. Entity beans are persistent.
I hope information in this post helps. If you’ve any feedback or want to share more on this topic then feel free to post in the comments.