Win a copy of Microservices Testing (Live Project) this week in the Spring 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 ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

EJBs and transactions

 
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have trouble understanding the J2EE transactions and database transactions.

I have an ejb which pulls data from one datasource, do some calculations and pushes the data to another data source.

When i push the data, i need to push it to more than 1 table and some times i have to insert more than one record on the same table. All this should happen in a single trnsaction.

Currently what we are doing is inserting a single row in table, committing it before inserting another record in another table. I believe this is wrong.

My options are pass the same connection to all the DAOs so that they can use the same connection and commit/rollback based on exceptions.

Are there any other mechanisms, other than passing the same connection to all the DAOs (because all the tables in the same database instance).

If so, what should i do in the DAOs? shall i remove all the commit/rollback statements from DAOs?

How do you solve this kind of problem when you want to talk two different types of databases and commit/rollback?

Any pointers??

Thank you very much.
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why cant you have container managed transaction (CMT)?

read this topic too
[ April 26, 2005: Message edited by: Kanishtha Kramalekhaka ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic