public static void merge(Object dest, Object orig) {
    String attr = "";
    try {
      Set attrs = org.apache.commons.beanutils.PropertyUtils.describe(orig).keySet();
      attrs.remove("class");
      for (Iterator it = attrs.iterator(); it.hasNext();) {
        attr = (String) it.next();
        if (!PropertyUtils.isWriteable(orig, attr)) {
          continue;
        }
        Object value = PropertyUtils.getProperty(orig, attr);
        if (null != value) {
          if (value instanceof Component) {
            Object savedValue = PropertyUtils.getProperty(dest, attr);
            if (null == savedValue) {
              PropertyUtils.setProperty(dest, attr, value);
            } else {
              merge(savedValue, value);
            }
          } else if (value instanceof Collection) {
            continue;
          } else if (value instanceof Entity) {
            Serializable key = (Serializable) PropertyUtils.getProperty(value, "id");
            if (null == key) {
              continue;
            } else if (new EmptyKeyPredicate().apply(key)) {
              PropertyUtils.setProperty(dest, attr, null);
            } else {
              PropertyUtils.setProperty(dest, attr, value);
            }
          } else {
            PropertyUtils.setProperty(dest, attr, value);
          }
        }
      }
    } catch (Exception e) {
      logger.error("meger error", e);
      if (logger.isDebugEnabled()) {
        logger.debug("error occur in reflection of attr:" + attr + " of entity " + dest.getClass().getName());
      }
      return;
    }
  }
public static void merge ( Object dest , Object orig ) { String attr = "" ; try { Set attrs = org . apache . commons . beanutils . PropertyUtils . describe ( orig ) . keySet ( ) ; attrs . remove ( "class" ) ; for ( Iterator it = attrs . iterator ( ) ; it . hasNext ( ) ; ) { attr = ( String ) it . next ( ) ; if ( ! PropertyUtils . isWriteable ( orig , attr ) ) { continue ; } Object value = PropertyUtils . getProperty ( orig , attr ) ; if ( null != value ) { if ( value instanceof Component ) { Object savedValue = PropertyUtils . getProperty ( dest , attr ) ; if ( null == savedValue ) { PropertyUtils . setProperty ( dest , attr , value ) ; } else { merge ( savedValue , value ) ; } } else if ( value instanceof Collection ) { continue ; } else if ( value instanceof Entity ) { Serializable key = ( Serializable ) PropertyUtils . getProperty ( value , "id" ) ; if ( null == key ) { continue ; } else if ( new EmptyKeyPredicate ( ) . apply ( key ) ) { PropertyUtils . setProperty ( dest , attr , null ) ; } else { PropertyUtils . setProperty ( dest , attr , value ) ; } } else { PropertyUtils . setProperty ( dest , attr , value ) ; } } } } catch ( Exception e ) { logger . error ( "meger error" , e ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "error occur in reflection of attr:" + attr + " of entity " + dest . getClass ( ) . getName ( ) ) ; } return ; } }
<pre>
merge函数主要用来将页面回传对象(orig)的参数合并到数据库已经存在的对象中.（浅拷贝）
合并的依据是待合并对象是否为空.如果对象是平面的component 则递归处理，如果是entity则检查是否是
有效的持久化对象（id不为空或者0）,那么将该对象复制过去，否则复制null.

这些页面对象中的集合属性不包括在复制和合并范围内.因为大多数页面参数中，很少有集合(Set)参数
况且如果把空集合合并到已有对象上，反而会造成(hibernate)删除已有对象和这些对象的关联，甚至对象本身
将orig中不为空的属性复制到dest中 added at
两个对象必须是同一类型的
</pre>

@deprecated
@see EntityUtil#evictEmptyProperty
@param dest
@param orig
影响dest