• Post Reply Bookmark Topic Watch Topic
  • New Topic

Simple Question on Stateful Session Bean

 
Bala Raj
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
State can be manintained in a Stateful session Bean, then can we say it's persistance?
Thanks,
Bala
 
Jorge Phillips
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bala Rajamani:
State can be manintained in a Stateful session Bean, then can we say it's persistance?
Thanks,
Bala

I assume your question is whether a stateful session bean is persistent. Persistence in its usual interpretation is related to the issue of scope, i.e. the life span of the bean. Session beans live only as long as their client's life span, i.e. only during the client session. Thus, their name. Entity beans on the other hand live as long as you want them to, i.e. they potentially have an indefinite scope. They do so by saving themselves in permanent storage (which survives machine boots, crashes, etc.) during and between sessions, possibly meaning storing themselves into a DB or other such permanent medium. Indefinite scope for a bean implies the bean saving itself to permanent storage, and in this case it is said that the bean is persistent.
Session beans live only during the session in which they are created. Thus by definition they have "session scope" and are not persistent, although they could save "persistent data". But once its session is over, a stateful session bean ceases to exist.
To clarify this even further, a stateless session bean is basically a functional object. A stateful session bean preserves state throughout method invocations for the extent of a session.This is done by keeping the stateful session bean's state in-memory or swapping it in and out of memory to temporary storage as needed.
I think this taxonomy makes a lot of sense as session beans are used to model and manage workflows while entity beans model and manage structured business data.
 
shivani anand
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think stateful session bean can be said Persistance. It's because persistant means that data is stored permanantly somewhere like database from where it can be retrieved latter on. In case of stateful session bean during passivation data is stored in secondary storage but that data is stored until the client is their or until the bean is not timed-out by the container.
I hope I am correct.
shivani
 
Ashok Jaganathan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simple way to tell the difference between Stateful session and Entity bean between is Stateful session bean maintains a conversational state and Entity beans are persistant as they can manintain the state even during server crash,it is not the same caese with stateful session beans.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!