beautypg.com

Adding dependency jar files, Adding dependency, Files – HP Integrity NonStop H-Series User Manual

Page 380

background image

String rord = ((Employee) command).getRord();
if (rord != null && rord.equalsIgnoreCase("Retrieve")) {
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
def
.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
TransactionStatus status = txManager.getTransaction(def);
Employee emp1;
try {
emp1 = empdao.getDetail(empid);
} catch (Exception e) {
// TODO: handle exception
txManager.rollback(status);
throw e;
}
txManager.commit(status);
Map model = new HashMap();
model.put("empid", "" + emp1.getEmpid());
model.put("empfn", emp1.getFirstname());
model.put("empln", emp1.getLastname());
model.put("empage", "" + emp1.getAge());
model.put("empemail", emp1.getEmail());
return new ModelAndView("retrieveresult", "model", model);
}
if (rord != null && rord.equalsIgnoreCase("Delete")) {
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
def
.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
TransactionStatus status = txManager.getTransaction(def);
String str;
try {
str = empdao.deleteEmployee(empid);
} catch (Exception e) {
// TODO: handle exception
txManager.rollback(status);
throw e;
}
txManager.commit(status);
Map model = new HashMap();
model.put("str", str);
return new ModelAndView("deleteresult", "model", model);
}
else {
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
def
.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
TransactionStatus status = txManager.getTransaction(def);
try {
empdao.insertDetail(empid, firstname, lastname, age, email);
} catch (Exception e) {
// TODO: handle exception
txManager.rollback(status);
throw e;
}
txManager.commit(status);
Map model = new HashMap();
model
.put("add",
"Transaction Complete - One Employee Added to Employee Database");
return new ModelAndView("insertresult", "model", model);
}
}
}

Adding Dependency

JAR

Files

Add the dependency

JAR

files to the build path of EmpInfo, based on the type of transaction as

explained below:

380

Using Spring Transaction Manager

This manual is related to the following products: