• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SessionSynchronization interface & session bean

 
Rashmi Tambe
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why can't a a STATELESS session bean implement the javax.ejb.SessionSynchronization interface ?
so can stateful session bean do that?
 
Mikalai Zaikin
Ranch Hand
Posts: 3371
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SessionSynchronization interface is used to notify bean of transaction state when transaction is spreaded over several methods calls.
Obviously, stateless bean can NOT have transaction which is spreaded over a couple of methods, because once method was called, stateless bean goes to pool and there is no chance to say for sure that next method will be called by the same client.
 
Rashmi Tambe
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mikalai !!!
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mikalai Zaikin:
SessionSynchronization interface is used to notify bean of transaction state when transaction is spreaded over several methods calls.

For SessionSynchronization, the transaction needs to be started always by the client?
SessionSynchronization is used only for CMT and transactions can spread across several methods only in BMT?
 
J Johny Rufus
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vish Kumar,
The concept of SessionSynchronization interface is there because it gives a stateful bean a chance to synchronize itself with any persistent data that it deals with.
For example if a stateful session bean has a persistent field, then inside afterBegin() it will be appropriate to load the current value from the database.
afterCompletion() should be used to store the persistent field, if the transaction was comitted sucessfully.
Thanx
RUF SCJP
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by J Johny Rufus:
Hi Vish Kumar,
The concept of SessionSynchronization interface is there because it gives a stateful bean a chance to synchronize itself with any persistent data that it deals with.
For example if a stateful session bean has a persistent field, then inside afterBegin() it will be appropriate to load the current value from the database.
afterCompletion() should be used to store the persistent field, if the transaction was comitted sucessfully.
Thanx
RUF SCJP


And SLSB do not maintain state.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic