Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception in a transaction question

 
gabriele rigamonti
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hiii

My question:

in EJB spec 2.0 the concepts :

"If the clients executes in a transaction,the client's transaction is not marked for rollback,and client can continue its work"

is confusing for me

Can help me?

Thanks !!

Gabriele
 
Severin Stoeckli
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"If the clients executes in a transaction,the client's transaction is not marked for rollback,and client can continue its work"


means:

the client of a EJB (that may be also an EJB) is running in a transaction, perhaps he made already some DB-changes. He calls annother EJB that has the transaction attributte, let's say "RequiresNew". This second EJB marks its transaction with "setRollbackOnly" (in the case of CMT). All DB-changes that were made by this second EJB are rolled back. However, since the client run's in his own transaction context, he may still commit the changes.

this behaviour would be different if second EJB would run with "requires". Then it would run in the same transaction context as the client, and all changes (those of the caller as well as those of the calle) would be rolled back.


Hope it helps :roll:

Severin
 
gabriele rigamonti
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Severin..

Thanks,now is clear

another precisation and for me the concepts are ok:

(in EJB spec pag 376) if the method trow ad example a runtime error i read that (the client) : "if the client executes in a transaction,the client's transaction may or may not be marked for roll back"

Can explain please the may or may not?

Thanks in Advance Severin

Gabriele
 
Severin Stoeckli
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's the same as before:

- if the client runs within the same transaction as the EJB it calls, the transaction will be rolled back. This is the case if the EJB's method is marked "Required" or "Supports".

- if the client runs with annother transaction context, ( "RequiresNew", "NotSupported" and "Never"), the client's transaction will not be rolled back.



hmm... its the first time I see a use for this "Supports" transaction attribute. :roll:



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