• Post Reply Bookmark Topic Watch Topic
  • New Topic

usage of sessionSynchronization  RSS feed

 
Balaji Mathyam
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys i need a small clarification regarding usage of sessionSynchronization. Correct me if have misunderstood...
If i am using a stateful session bean, the container is responsibe for managing transactions(commit or rollback) and managing state of the bean before transaction. so, when the container is managing the state of the bean, why should we implement sessionSyncronisation for caching the state of the bean before transaction.

Thanking you in Advance...
Balaji.
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Balaji Mathyam:
If i am using a stateful session bean, the container is responsibe for managing transactions(commit or rollback) and managing state of the bean before transaction. so, when the container is managing the state of the bean, why should we implement sessionSyncronisation for caching the state of the bean before transaction.

The SessionSynchronization interface just gives a Stateful Session Bean the option of to being notified by its container of transaction boundaries. There are numerous reasons why this could be useful.
The typical example is the need to undo changes to a Stateful Session Bean's state if the transaction that it is participating in is rolled back. The Stateful Session Bean would make a copy of its state during afterBegin() and then if the transaction is rolled back it would restore the old state during afterCompletion().
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!