Currently I am working on a DAL design, I have concern regarding managing transaction in Business Layer(BL) while keeping it unaware of DB technologies.
For ex: I have two DAOs
SalesOrderDAO, SalesOrderItemDAO
At some point in BL I would like to call update/create method on both in a transaction:
// some where in BL
SalesOrderDAO soObj = new SalesOrderDAO();
SalesOrderItemDAO soiObj = new SalesOrderItemDAO();
//transaction start
soiObj.create(); // it could be update as well
soObj.update();
//on some condition transaction roll back
//transaction end
How to acheive it?
Constraint:
(Am I missing something?)
I did some research(after i received comment on question) I found spring have all I needed.
Say, in BL we have method: SomeBLMethod(), which does db operation using SalesOrderDAO, SalesOrderItemDAO and SomeBLMethod should be under transaction. We need to do following to make Transaction work:
Reference:
PS: I am adding this answer to help others.