• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

why stateless session bean cannot implement SessionSynchronisation?

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
We don't have time to be charming! Quick, read this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic