i am trying to achieve spring boot Transaction service layer bit not able to achieve:
Here is my code
@Service
public class EmpService {
@Autowired
EmployeeDao employeeDao;
@Autowired
EmployeeRepo empRepo;
@Autowired
EmployeeHealthInsuranceRepo healthRepo;
@Transactional
public void insertEmployee1(Employee employee,EmployeeHealthInsurance employeeHealthInsurance) {
empRepo.save(employee);
System.out.println(100/0);
healthRepo.save(employeeHealthInsurance);
}
public void insertEmployee(Employee employee,EmployeeHealthInsurance employeeHealthInsurance) {
insertEmployee1(employee,employeeHealthInsurance);
}
}
i am expecting roll back if any error occuer from database or any code level