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.