Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

Reg SessionSynchronization Interface

Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is stated in the HF EJB book that "Stateless session beans cannot use SessionSynhronization Interface becuase stateless session beans cannot maintain a transaction once method has ended".

How is this true even in the case of CMT beans. Cant we just maintain the transaction across the "stateless CMT beans" methods using appropriate trans-attributes.

Author & Gold Digger
Posts: 7617
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, for completeness' sake, a stateless session bean with bean-managed transaction demarcation MUST commit any transaction before the end of its business methods as stated in the EJB spec 2.0 section 17.3.3.

As for stateless CMT beans, there is no way to let a transaction span across multiple calls using transaction attributes since you, the bean provider, are not in charge of managing transactions because you charged the container to do it. And since transaction demarcations are specified on a per method basis in the deployment descriptor, CMT stateless session beans cannot maintain transactions across multiple calls. You should use stateful session beans for that purpose. Note that the role of transaction attributes is NOT to let you span a transaction across several calls but just to hint the container at how method-level transactions should be managed.
Joel Salatin has signs on his property that say "Trespassers will be Impressed!" Impressive tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
    Bookmark Topic Watch Topic
  • New Topic