I have below method call hierarchy
public class UpdateProcess {
public void startingMethod(List<Object> objects){
for (Object obj : objects) {
method1(obj);
}
}
@Transactional
public void method1(Object obj) {
method2(obj);
}
public void method2(Object obj) {
EmployeeService.updateObject(obj)
}
}
public class EmployeeService
@Transactional
public void updateObject(Object obj) {
return customerDao.update(obj);
}
}
In above scenario, My expectation is spring should commit the transaction as thread comes out of Method1 or rollback if exception occurs anywhere in hierarchy.
But spring is committing the transaction as soon as update is executed in method2. I am not getting why ?
UPDATE:- Even if I change @Transactional
to @Transactional(propagation=Propagation.REQUIRES_NEW)
its still committing the transaction. So No impact