• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transaction Context in Stateful Session Bean

 
Eusebio Floriano
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • 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 ?
 
alzamabar
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • 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.
 
Severin Stoeckli
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think yo'r absolutely right, Marc

Severin
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic