I have a service which do some work:
@Service
@Transactional
public class FooServiceImpl implements FooService {
@Override
public void invoke() {
process();
}
public void process() {
// possible that will throw exception
elements.forEach -> processOne(..)
}
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void processOne(..) {
// possible that will throw exception
}
}
The invoke()
method is called from another component. As I understand this method is running within transaction (if exist - continute, if not - create new one). But what I expected - method processOne(..)
is running in new transaction - so if in this one everything is ok transaction should be commited. But if error occur then whole process is rolled back. Not only from current transaction. What's wrong ?