We are refactoring a legacy application. The old code did something like this in a Controller method:
- Call DAO1.update()
- Call DAO2.update()
We’ve placed an in between a service layer, so the above code now looks like:
- Call Service1.update() --> Call DAO1.update()
- Call Service2.update() --> Call DAO2.update()
Each of the above two update methods have been marked transactional (using spring transactions). Old code didn’t handle transactions that well – now, we want a user action (controller method) to map only to a single transaction. How can we achieve that using spring transactions itself?
PS:
- We did checked Hibernate’s Open Session in View pattern, but we would like a solution that makes use of Spring transactions – the above scenarios are not that common and we are worried about performance decay in OSIV pattern.
- We can combine the two service methods above into a single method but would welcome a bit cleaner situation that won’t hinder reuse.