Transaction tx = null;
try {
aSession = getSession();
tx = aSession.beginTransaction();
SbiGoal hibGoal = new SbiGoal();
hibGoal.setName(goal.getName());
hibGoal.setLabel(goal.getLabel());
hibGoal.setDescription(goal.getDescription());
hibGoal.setStartDate(goal.getStartDate());
hibGoal.setEndDate(goal.getEndDate());
hibGoal.setGrantId(goal.getGrantId());
updateSbiCommonInfo4Insert(hibGoal);
if(goal.getId()!=null){
hibGoal.setGoalId(goal.getId());
aSession.update(hibGoal);
tx.commit();
}else{
aSession.save(hibGoal);
tx.commit();
goal.setId(hibGoal.getGoalId());
}
} finally {
rollbackIfActiveAndClose(tx, aSession);
}
logger.debug("OUT: OrganizationalUnit inserted successfully with id " + goal.getId());