try {
aSession = getSession();
tx = aSession.beginTransaction();
boolean save = true;
SbiUser userToUpdate = user;
id = userToUpdate.getId();
Set<SbiExtUserRoles> extUserRoles = new HashSet<SbiExtUserRoles>();
Set<SbiUserAttributes> userAttrList = new HashSet<SbiUserAttributes>();
if(id!=0){
save = false;
userToUpdate =(SbiUser)aSession.load(SbiUser.class, id);
if(user.getPassword() != null && user.getPassword().length() > 0){
userToUpdate.setPassword(user.getPassword());
}
userToUpdate.setFullName(user.getFullName());
userToUpdate.setUserId(user.getUserId());
userToUpdate.setId(id);
updateSbiCommonInfo4Update(userToUpdate);
}
if(save){
updateSbiCommonInfo4Insert(userToUpdate);
id = (Integer)aSession.save(userToUpdate);
userToUpdate.setId(id);
}
//sets roles
if(roles != null){
//remove existing roles