This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Transaction propagated from JTA to CMT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Transaction propagated from JTA to CMT" Watch "Transaction propagated from JTA to CMT" New topic
Author

Transaction propagated from JTA to CMT

Solo Chiang
Greenhorn

Joined: Sep 14, 2005
Posts: 18
Here is my question, I am trying to have a transaction propagated from JTA to CMT, will it work?

I have two entity beans adopted CMT for one of its business method.
I have a Struts Action class that will call these two entity bean one by one for two database update respectively.

In order to put these two database changes into a single transaction,
can I use JTA (ut.begin() & ut.commit()) to enclose two method invocation for these two entity bean and specify transaction attribute as "Required" in these two business method to achieve my goal?
[ October 12, 2007: Message edited by: Solo Chiang ]
Shailesh Kini
Ranch Hand

Joined: Oct 17, 2001
Posts: 153
Solo,

My thoughts...

Yes, the EJB container supports JTA by default... at least from J2EE 1.4 not sure about earlier versions. You do not have to call ut.begin() or ut.commit() manully. You can have the container manage it for you.

However by default your JDBC Datasource does not participate in XA so you have to change the JDBC datasource interface from javax.sql.DataSource to javax.sql.XADatasource for both the datasources.

Your session bean will have a Required attribute and so will your entities.


Shailesh Kini.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Transaction propagated from JTA to CMT
 
Similar Threads
Transaction-propagation
Two connections in one transaction?
HFEJB page 366 question no 18
A basic Question on ejbLoad and ejbStore
Passed SCBCD 5.0 :)