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 ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

sample Question

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

Given:
Bean A with transaction attributes of "RequiresNew" for all its methods.
Bean B with transaction attributes of "Supports" for all its methods.
A client having a transaction context calls a method mA() on bean A, which in turns calls a method mB() on Bean B.

Assuming all invocations are local, which of the following statements is correct if mB() encounters a system exception?

Options

Select 3 correct options.

1) The client's transaction will be marked for roll back.
2) The client will get a javax.ejb.EJBException but it can continue with the same transaction.
3) The client will get a javax.ejb.TransactionRolledbackLocalException
4) The bean B instance will be discarded.
5) mA() will get a javax.ejb.TransactionRolledbackLocalException
6) The bean A instance will NOT be discarded.
7) Changes made to the database by mA(), will be commited.

The correct answers marked was 2,4,5. but i disagree with 2 being correct. the spec only states that the client tran may or may not be marked for rollback.

Has this kind of questions appeared on the real exam?
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,
The option "The client will get a javax.ejb.EJBException but it can continue with the same transaction" does not mean that the client transaction is rolledback. I feel that it's a way of informing the client that something bad has happened during the execution of method A. Now it's upto the client to decide if it should continue the transaction it owns or not.

Ranchers,
Please correct me if I am wrong.

HTH,
Sandeep
 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Srividhya,
I think we discussed this question before.
choice 2 confuses some times..

see, Client running/calling his methods may be in a transaction or not in a transaction and calls methods on Bean A which starts a new transaction which is TxA and you get exception in that transaction. So you just inform back the client that some thing went wrong in TxA and its upto the client to decide to roll back his transaction or not.

Client(TxC or no transaction) ------> Bean A (TxA) ------> Bean B (TxA)

Hope this time this is clearer.

Thanks,
Ugender
[ June 28, 2006: Message edited by: Ugender Rekulampally ]
 
She'll be back. I'm just gonna wait here. With this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic