This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt regarding transaction context

 
Senthil Kumar
Ranch Hand
Posts: 264
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In ejb3-core-spec page no 360 table 14 about Handling of exceptions


Bean method runs in the context of the caller�s transaction [Note A].

[A] The caller can be another enterprise bean or an arbitrary client program.


can someone tell me how a client other than a bean will have a transaction context be associated with.
 
Senthil Kumar
Ranch Hand
Posts: 264
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
would like to clarify some more doubts.

Assume i have a bean class with CMT. And i am calling methodA in the bean which starts out a transaction(having Required/Required_new attribures).This is followed by the subsequent calls to the other methods of the bean class which are all having their own transaction attributes that might let the bean to continue with the existing transaction context,else to start a new one, or even to destroy the existing.

my doubt is,

1. when the container does the commit for the existing transaction started by the first method.

2.In core specs page no 360, first case under container's action why there is no info about calling setRollbackOnly().Is it not possible to set the transaction to rollback when it's the one from the caller's
 
Shivani Chandna
Ranch Hand
Posts: 380
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Senthil,

You can use Application Client (which is similar to standalone java client) to call EJB and this client can create a transaction prior to calling.

"The client can leverage standard J2EE artifacts such as InitialContext, UserTransaction, and EJBs."

Read more about Application Client:
J2EE Application Client


first case under container's action why there is no info about calling setRollbackOnly().Is it not possible to set the transaction to rollback when it's the one from the caller's


The first action that container will take is to propagate back the exception (along with marking Tx for rollback if needed) . Since the transaction was initiated by the client. It is the client which will rollback after checking for status and knowing if setRollback was invoked by another bean that took part in Tx.

So - the one who starts it : in that bean there is a check for the status and rolling back if needed.

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