How to make transactions span multiple DAO-ops?
Hi!
This is a question about DAOs, business objects and how to make their (i.e the business objects) transaction-safe.
One of the Spring distribution samples contains a LogicFacade backed up by a LogicFacadeImpl which is regarded as the primary (and only) business object. Transactions works well, no problems there, and I'm even beginning to understand some of the mechanisms behind it.
However, I've been searching for information regarding the use of BOs from a transactional point of view. My idea is to limit the number of methods in the DAO, maybe CRUDs only and to make the DAO member of a BO, and then invoking its DAO member. One reason for this is mr Johnson's advice in his "J2EE Dev. wo EJB" to avoid large "God objects" like for example LogicFacade.
My question is; is it possible to make a construct like
Code:
public Object invoke(Object command){
getDao().performDBOperation();
//etc
//etc
getDao().performAnotherDBOperation();
.
.
}
transactional, ie if 'performAnotherDBOperation' fails, 'performDBOperation' is rolled back?
Of course both DB-operation have their individual transaction safeness, but how do I make them work as a "team"?
I hope my question is understandable.
Thanks!
Sincerely,
/The Cantor
"Murphy was an optimist"
(The O'Toole commentary on Murphy's Law)