I am using Spring 2.5 transaction management, and I have the following setup:
Bean1
@Transactional(noRollbackFor = { Exception.class })
public void execute() {
try {
bean2.execute();
} catch (Exception e) {
}
}
Bean2
@Transactional
public void execute() {
}
A failure is never saved to the database from Bean1 because the whole transaction is rolled back.
I do not want to add noRollbackFor to Bean2 because it is used in many places that do not have logic for correctly handling runtime exceptions.
Is there a way to avoid rolling back my transaction only when Bean2.execute () is called from Bean1?
Otherwise, I think my best option is to keep my refusal in a new transaction? Anything else I can do?