code: public static void evictEmptyProperty(Object entity) {
      if (null == entity) { return; }
      boolean isEntity = false;
      if (entity instanceof Entity) {
        isEntity = true;
      }
      BeanMap map = new BeanMap(entity);
      List<String> attList = new ArrayList<String>();
      for (Object o : map.keySet()) {
        attList.add((String) o);
      }
      attList.remove("class");
      for (String attr : attList) {
        if (!PropertyUtils.isWriteable(entity, attr)) {
          continue;
        }
        Object value = map.get(attr);
        if (null == value) {
          continue;
        } else {
          // evict invalid entity key
          if (isEntity && attr.equals("id")) {
            if (!ValidEntityKeyPredicate.Instance.apply(value)) {
              map.put(attr, null);
            }
          }
          // evict invalid entity
          if (value instanceof Entity && !ValidEntityPredicate.Instance.apply(value)) {
            map.put(attr, null);
          } else if (value instanceof Component) {
            // evict component recursively
            evictEmptyProperty(value);
          }
        }
      }
    }
docs: 清除实体类中引用的无效(外键)属性.<br>
  
  <pre>
  hibernate在保存对象是检查对象是否引用了未持久化的对象，如果引用则保存出错.
  实体类(Entity)是否已经持久化通过检查其id是否为有效值来判断的.
  对于实体类中包含的
  &lt;code&gt;
  Component
  &lt;/code&gt;
  则递归处理
  因为集合为空仍有其含义，这里对集合不做随意处理.如
  // evict collection
  if (value instanceof Collection) {
  if (((Collection) value).isEmpty())
  map.put(attr, null);
  }
  </pre>
  
  @see ValidEntityPredicate
  @param entity