I have a 3 layer web application which uses these frameworks: struts, spring and hibernate. in action class I have called a method in business logic layer which update data in a specific table. now I have to call another class to insert data in another table, these are different tables so have different classes in business logic layer and DAO layer. I want to have data integrity means if the second insert failed, I have to rollback the first one. how could I control it in action class.
try{
policyIssuanceManagement.updatePolicy(currentPolicy);
String result=policyDetailManagement.insertDataInPolicyDetail(policyId, riskAmount, riskPercent, riskId, regionRisk, regionPercent, regionId, stepped, steppedPercent, steppedId, discount, discountPercent, discountId);
}
catch (Exception e) {
e.printStackTrace();
}
I can not roll back the updated policy.