Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJBs and transactions

 
Sreenivasa Majji
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • 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.
 
Mudi Appu
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • 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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic