Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

Transaction propagated from JTA to CMT

Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
Farmers know to never drive a tractor near a honey locust tree. But a tiny ad is okay:
Free, earth friendly heat - from the CodeRanch trailboss
    Bookmark Topic Watch Topic
  • New Topic