Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need example of calling an EJB method with a transaction context

Status
Not open for further replies.

thelordoftherings

Programmer
May 16, 2004
616
IL
Hello,

The transaction attribute "Mandatory" define that the business method associated with this attribute must be called by the client with a valid transaction context.
Can someone please show me a simple client example of calling an EJB business method with a transaction context? meaning how the client creates it ad relates it to the business method?

Regards,
Roy
 
Are you using Container Managed Transactions? If so, it supplies the tx context.

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
Hey Tim,

Can you please show me code example from the client side of both cases (CMT/BMT)?
 
Never done any BMT.
For a bean method with a 'Mandatory' Tx setting, it is usually used as part of other in-progress transactions. Whenever I've used this, its been from another method which had a setting of something like 'Required', so that the container supplies the initial tx, and this then propagates to the method set as 'Mandatory'.

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
But when you used with 'Required' how do the client transfer the tx when it calles the business method, using a special object or what?
 
Required, means that the container will create a tx context if one is not already available.

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
I know but how do I make one available?
Lets say I am calling a 'Mandatory' method from the client, this means that the call must be with tx/ Well, how do the client creates it then?
 
Well, I've never needed to do that and I don't know if it's possible. Why do you have to set it as 'Mandatory'? If it needs a tx, set it as 'Required' so that the container will create the tx context for you.

As far as I know, 'Mandatory' is only of use when the method is called by some other method in your EJB server application. For remote methods which could be called from a remote client, use the 'Required' setting.

If anybody else could correct or confirm this, please do so. I don't want to confuse the OP.

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
Hey tim,
I don't need to call such method and I define it as you suggested. This case is a hypothetical one which I thought about and couldn't find a solution either. Agree with me that this situation can be created, the question is how to solve it... :)
 
Sorry, thelordoftherings. I don't really have time right now to solve hypothetical questions. Real-life problems are getting in the way.

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
This is a hypothetical problem that could be real one at any time... know what? ooops it just does...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top