I have read this post and it doesn't answer my question. Stateless session bean with instance variables I am reading the JEE5 tutorial and on this page it states http://download.oracle.com/javaee/5/tutorial/doc/bnbly.html " Clients may, however, change the state of instance variables in pooled stateless beans, and this state is held over to the next invocation of the pooled stateless bean "
I don't agree with this.. coz i thought keeping 'any' kind of state across invocations of different instance of beans was something you need 'stateful' session beans for.
Please help me understand this thx in advance Rooban
In EJB the distinction between "stateful" and "stateless" refers to conversational state, not simply Java object state (that is, any use of instance fields).
From Wikipedia:
In a stateful session bean, the instance variables represent the state of unique client-bean sessions. The interaction of the client with bean is called as conversational state.
The classic example is that of a shopping cart for an ecommerce application. You'd use a SFSB to store the "cart" object because it needs to maintain conversational state between requests.
On the other hand:
A stateless session bean is an object that does not have an associated conversational state, but may have instance state. It does not allow concurrent access to the bean. The contents of instance variables are not guaranteed to be preserved across method calls. All instances of a stateless session bean should be considered identical by the client.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With