Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why stateless session bean cannot implement SessionSynchronisation?

 
Prashant Neginahal
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

why stateless session bean cannot implement SessionSynchronisation?My thought behind this question is, even for stateless session bean, once the business method execution starts that instance will not be shared by other clients.And, stateful session bean is always client specific. So, i guess nuthing wrong in implementing SessionSynchronisation even for stateless bean.

Thanks,
Prashant
 
KasiMurugan Ramasamy
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Prahant

Purpose of SessionSynchronization interace is to maintain the Instance state( stateful feild )( like persistent field in entity bean) consistently ( if current transaction is failure revert the instance state to previous ) for the next business method call on the same instance.

but stateless instance are each business method processed by might be different instance.

I hope it help you.

Regards
Kasimurugan R.
 
Prashant Neginahal
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont know whether i understood u correctly. This scoping of transaction across multiple methods is possible for ONLY BMT stateful session beans. SO, my question is why stateless session bean with CMT cannot implement this interface?

Thanks,
Prashant
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stateless session beans cannot implement the SessionSynchronisation interface because they cannot maintain a transaction after a method has finished.

Stateful session beans can keep a transaction open across multiple method invocations, but they have a problem: how can they know when to synchronize themselves with a database? As they do not have the entity beans' ejbLoad() and ejbStore() methods, an alternative system is needed. That system is the SessionSynchronisation interface, which defines when a transaction starts, when a transaction is about to end, and when a transaction is finished (the afterBegin(), beforeCompletion() and afterCompletion() methods respectively).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic