In Spring, is there a way I can access the properties of the unitofwork across the DAO's?
Let's assume I have a service layer:
public Class A {
impl.setUnitOfWork(details);
daoA.saveA(dto.getEntityADetails())
daoB.saveB(dto.getEntityBDetails());
}
pubcli class Impl extends TopLinkDaoSupport {
public void setUnitOfWork (TxnDetailsDTO details) {
getSection().getTopLinkTemplate().execute (new UnitOfWorkCallback() {
protected object doInUnitOfWork (UnitofWork uow) {
uow.setProperty ('prop1', details);
return null;
}
});
}
}
public Class DAOA {
public saveA (DTO dto) {
getSection().getTopLinkTemplate().execute (new UnitOfWorkCallback() {
protected object doInUnitOfWork (UnitofWork uow) {
if (uow.getProperty('prop1'))
uow.registerObject(dto);
return null;
}
});
}
}
public Class DAOB {
public saveB (DTO dto) {
getSection().getTopLinkTemplate().execute (new UnitOfWorkCallback() {
protected object doInUnitOfWork (UnitofWork uow) {
if (uow.getProperty('prop1'))
uow.registerObject(dto);
return null;
}
});
}
}
I understand that the setProperty() of uow is inherited from the session.
How can I make sure that all the uow's I access in the callback share the same session in Tomcat with Spring? I am having the session instance as FinalizedClientSession when i listen to the uow.