//loop over db attributes for user
Iterator attrsIt = userAttributes.iterator();
while(attrsIt.hasNext()){
//if attribute is modified than update
SbiUserAttributes attribute = (SbiUserAttributes)attrsIt.next();
Integer attrID = attribute.getId().getAttributeId();
if(attributes.containsKey(attrID)){
String attrVal = attributes.get(attrID);
attribute.setAttributeValue(attrVal);
//checks if value ==""
if(attrVal.equals("")){
aSession.delete(attribute);
}else{
updateSbiCommonInfo4Update(attribute);
aSession.saveOrUpdate(attribute);
}
aSession.flush();
attributes.remove(attrID);
}
}//else if attribute is not present than add it
Iterator attrsItToAdd = attributes.keySet().iterator();
while(attrsItToAdd.hasNext()){
Integer attrID = (Integer)attrsItToAdd.next();
SbiUserAttributes attributeToAdd = new SbiUserAttributes();
attributeToAdd.setAttributeValue(attributes.get(attrID));
SbiUserAttributesId attributeToAddId = new SbiUserAttributesId();
attributeToAddId.setId(id);
attributeToAddId.setAttributeId(attrID);
attributeToAdd.setId(attributeToAddId);
updateSbiCommonInfo4Insert(attributeToAdd);
aSession.saveOrUpdate(attributeToAdd);
aSession.flush();
}