Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transaction Question

 
Ashley Bideau
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?



Select 2 correct options

a The client's transaction will be marked for roll back.

b The client will get a javax.ejb.EJBException but it can continue with the same transaction.

c The client will get a javax.ejb.TransactionRolledbackLocalException

d mA() will get a javax.ejb.TransactionRolledbackLocalException

e The bean A instance will NOT be discarded.

f Changes made to the database by mA(), will be commited.
 
Rajesh Chande
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ashley,

I would normally opt for "a" and "c" on the following basis:

req. New supports
client ------> a.mA -------> b.mb
T1 T1
Sys Ex.

so - T1 marked for rollback.
- Client will get javax.ejb.TransactionRolledbackLocalException

Anybody.. correcting me?
 
TeGo Gokhale
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thin correct answer is B and D

with requiresnew a new tx was started.

So say client' stx was txcl
mA() would suspend txcl and would run in new txnew
mB() would also run in txnew.

So on system exception txnew would be rolled back. so mA() would get txrolledback excptn.

Container would give ejbexception to client. But clients txcl is still alive and he can continue with it.
 
paresh vernekar
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I think the correct answers are d & e.
For bean B, the client is bean A.Since bean A is running in a new transaction and bean B runs in the same transaction, when exception occurs in bean B, it would be bean A which receives the javax.ejb.TransationRolledbackLocalException.Also since the exception has occurred in bean B, there is no need to discard the instance of bean A.
Option a is not correct because the exception doesnot occur in client transaction
Option b is not correct because for bean B, the client is bean A
Option c is not correct for the same reason
Option f is not correct because the exception occurred when bean B was running in the transaction context of bean A
Please correct me if the above reasoning is wrong

Regards,
Paresh Vernekar
 
TeGo Gokhale
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be you are correct, but what i think is since the transaction in which Bean A was running has been marked to rollback, there is no reason for container not discarding beanA.

Option B seems to be correct because though beanA is client to beanB but the component who invoked mA() is client to beanA who would get ejbException and that is the client which is reffered to in option B
 
Abhinav Prakash
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The correct options should be 'a' and 'e'.

since a system exception occured the transaction is marked for roll back. And since the System exception occured in bean B , it is discarded, but that does not Bean A will be discarded.
 
Rajesh Chande
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

After rethinking on it, I change my opinion to "d" and "e".

it was a good one... ;-)

Regards,
Tiro.
 
Ugender Rekulampally
Ranch Hand
Posts: 135
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
E will be wrong option to pick ..since the exception is generated in TxA context (transaction A). In this case, the instance will be discarded. you dont want to keep the values even if you get a transaction exception in the same transaction context, or else it will keep your system in inconsitent state (may be dirty values).

The option A is wrong because, client get the exception(javax.ejb.EJBException) notice from transaction context A but it is upto the client to decide to continue the transaction or not. So the option B is correct.

The correct answers are B and D.



Thanks,
Ugender

[ July 19, 2006: Message edited by: Ugender Rekulampally ]
[ July 19, 2006: Message edited by: Ugender Rekulampally ]
 
Ashley Bideau
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys for all the replies.
 
paresh vernekar
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have changed my opinion too.Ugender is right about B and D being the correct options

Regards,
Paresh Vernekar
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic