Stateful Session bean:-
- Stateful session bean maintain the state of the conversation between the client and itself
- When the client invokes a method on the bean the instance variables of the bean may contain a state but only for the duration of the invocation
- implements the javax.ejb.SessionBean interface and is deployed with the declarative attribute "stateful"
Stateless session bean:-
- A stateless session bean is an enterprise bean that provides a stateless service to the client.
- Conceptually, the business methods on a stateless session bean are similar to procedural applications or static methods; there is no instance state, so all the data needed to execute the method is provided by the method arguments
- implements the javax.ejb.SessionBean interface and is deployed with the declarative attribute "stateless
See the following video on Factory Pattern in Hibernate: -
Click to get Java Training
Get more Java Training from author’s blog