Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Transaction Context in Stateful Session Bean

 
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

The bean provider must not use javax.ejb.SessionContext.getRollbackOnly() and javax.ejb.SessionContext.setRollbackOnly() in the callbacks ejbRemove, ejbCreate, ejbPassivate and ejbActivate because there is no tx context, rigth?
So, why is it possible to use ejb.SessionContext.getUserTransaction and its methods in this callbacks ?
 
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Vinicius Boson:
Hi,

The bean provider must not use javax.ejb.SessionContext.getRollbackOnly() and javax.ejb.SessionContext.setRollbackOnly() in the callbacks ejbRemove, ejbCreate, ejbPassivate and ejbActivate because there is no tx context, rigth?
So, why is it possible to use ejb.SessionContext.getUserTransaction and its methods in this callbacks ?




I'm not sure about my answer but I'll give it a go: while with CMT is the container which manages the transaction based on the DD and the client's transactional status, with BMT is the developer who starts and ends transactions. When the container is involved, it lets clients to deal with transaction-related methods in a 'meaningful transaction context'. In ejbRemove, the container is about to put the bean in a 'does not exist' state, therefore where is the 'mtc'? With activation/passivation we know that a bean cannot be passivated while in the middle of a transaction therefore activation/passivation and CMT don't get on very well...With the create method, the container has only create an EJB[Local]object, waiting for a business method to be invoked on it, therefore also here I can't see any 'mtc'.

Hope to have said at least (*one*) thing right.
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think yo'r absolutely right, Marc

Severin
 
reply
    Bookmark Topic Watch Topic
  • New Topic