• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

transaction question.

 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Foks, pleas help me on the following statement:

"If the client calls with a transaction context, the behavior is similar to REQUERIED" --> "SUPPORTS".

Right, I agree with because it keeps the same transaction and continue running normally.

My question is..why cannot i say that "mandatory" could also be a correct response in this case? Because it also keeps the same transaction and continue running normally!!!

Please advise!!!

Tks in advance! ;-)
 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just fixing a typo: *REQUIRED instead of REQUERIED!
 
Camilo Morales
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The difference between SUPPORTS and MANDATORY is that MANDATORY will throw an exception if it is invoked without a Tx context. Take a look at the following fragment from Mikalai Zaikin Notes for SCBCD 5.0:


MANDATORY

The container must invoke an enterprise bean method whose transaction attribute is set to MANDATORY in a client's transaction context. The client is REQUIRED to call with a transaction context.

If the client calls with a transaction context, the container performs the same steps as described in the REQUIRED case.

If the client calls without a transaction context, the container throws the javax.ejb.EJBTransactionRequiredException. If the EJB 2.1 client view is used, the container throws the javax.transaction.TransactionRequiredException exception if the client is a remote client, or the javax.ejb.TransactionRequiredLocalException if the client is a local client.


(The only two Tx types that will throw exception are NEVER and MANDATORY.)

So, you are right, according to MZ notes:


"If the client calls with a transaction context, the behavior is similar to REQUERIED" --> "SUPPORTS" AND MANDATORY.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic