I am working with some legacy code where all the Spring DAOs are annotated with @Transactional annotation. Now I have a business requirement where I need to call two different DAOs in my service layer and rollback the transaction if it fails at any point.
How do I achieve this in Spring 5 without removing the @Transactional annotation from DAOs and still use them from the service layer. I don't think the code below will work as the transaction in each DAO would be independent of each other.
Many thanks in advance.
@Transactional
public FooDao {
}
@Transactional
public BarDao {
}
@Transactional
public TestServiceImple implements TestService {
fooDao.action1();
barDao.action2();
}