@Override
    public void update(Object entity) {
        if (null == entity) {
            return;
        }
        
        if (!(entity instanceof Persistent)) {
            create(entity);
            return;
        }
        
        String dn = DnHelper.build(entity);
        List<ModificationItem> mods = fromEntityToModificationItems(entity);
        if (mods.isEmpty()) {
            LogUtils.debug(LOG, "no changes found when updating dn=" + dn + ", do nothing");
            return;
        }
        
        LogUtils.debug(LOG, "update dn=" + dn);
        
        try {
            ctx.modifyAttributes(dn, mods.toArray(new ModificationItem[0]));
            
            /*
             * All current modifications are cleared, so could we continue
             * to use this entity? The answer is no!
             * 
             * For simple string properties, this works fine. But for
             * multiple values we need to do following things before reusing
             * this entity:
             * 1. clear changes of all the modified MonitoredList
             * 2. turn normal List into MonitoredList
             */
            EntityProxyFactory.getModifiedPropNames(entity).clear();
            for (EntityPropertyMetaData propMetaData : EntityMetaData.get(ClassHelper.actualClass(entity))) {
                if (propMetaData.isReadonly() || !propMetaData.isMultiple()) {
                    continue;
                }
                
                Object propValue = propMetaData.getter().get(entity);
                if (null == propValue) {
                    continue;
                }
                
                List propValues = (List) propValue;
                if (propValues instanceof MoniteredList) {
                    // clear changes of all the modifed MoniteredList
                    ((MoniteredList)propValues).clearChanges();
                } else {
                    // turn normal List into MoniteredList
                    propMetaData.setter().set(entity, new MoniteredList(propValues));
                }
            }
            
            /*
             * Now we have no need to remove the entity from the cache. And its
             * possible to continuous use of the entity.
             */
            
        } catch (NamingException e) {
            throw new SessionException(e.getMessage(), e);
        }
    }