This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Transaction-propagation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Transaction-propagation" Watch "Transaction-propagation" New topic
Author

Transaction-propagation

Oliver Rensen
Ranch Hand

Joined: Jul 23, 2004
Posts: 109

Hello ranchers,

I have a doubt regarding transaction-propagation.

In a session-bean a method is started with the tx-attribute RequiresNew. This method calls an application-service (a POJO). The application-service contains business-logik and calls an entity-bean for persistence. The methods in the entity-bean have all the tx-attribute Mandatory.

Does the transaction from the session-bean-method (created with RequiresNew) will be propagated through the POJO-application-service to the entity-bean?

Is the POJO be able to rollback the transaction?

When the session-bean would be directly call the entity-bean, it would be clear, that the transaction will be propagated from the session-bean to the entity-bean. But what happens if there is a POJO between session-bean and entity-bean?

Regards,
Oliver
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

Hi Oliver,
Transaction contexts are stored in thread local variables.
So, if the POJO does not spawn a new thread(not allowed as per ejb specs) and call the entity bean in that thread, the transaction context will be propagated to the entity bean.
Will the POJO be able to rollback the transaction?

Yes, if the session bean provides it with its user transaction object(BMT) OR session context object(CMT).


apigee, a better way to API!
Oliver Rensen
Ranch Hand

Joined: Jul 23, 2004
Posts: 109

Nitesh, thanks a lot for your help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Transaction-propagation