object/src/main/java/com/orientechnologies/orient/object/enhancement/OObjectProxyMethodHandler.java
public void detach(final Object self, final boolean nonProxiedInstance)
      throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {

    final Class<?> selfClass = self.getClass();

    for (String fieldName : doc.fieldNames()) {
      Object value = getValue(self, fieldName, false, null, true);
      if (value instanceof OObjectLazyMultivalueElement) {
        ((OObjectLazyMultivalueElement<?>) value).detach(nonProxiedInstance);
        if (nonProxiedInstance)
          value = ((OObjectLazyMultivalueElement<?>) value).getNonOrientInstance();
      }
      OObjectEntitySerializer.setFieldValue(OObjectEntitySerializer.getField(fieldName, selfClass), self, value);
    }
    OObjectEntitySerializer.setIdField(selfClass, self, doc.getIdentity());
    OObjectEntitySerializer.setVersionField(selfClass, self, doc.getVersion());
  }
public void detach(final Object self, final boolean nonProxiedInstance)
      throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {

    final Class<?> selfClass = self.getClass();

    for (String fieldName : doc.fieldNames()) {
      Object value = getValue(self, fieldName, false, null, true);
      if (value instanceof OObjectLazyMultivalueElement) {
        ((OObjectLazyMultivalueElement<?>) value).detach(nonProxiedInstance);
        if (nonProxiedInstance)
          value = ((OObjectLazyMultivalueElement<?>) value).getNonOrientInstance();
      }
      OObjectEntitySerializer.setFieldValue(OObjectEntitySerializer.getField(fieldName, selfClass), self, value);
    }
    OObjectEntitySerializer.setIdField(selfClass, self, doc.getIdentity());
    OObjectEntitySerializer.setVersionField(selfClass, self, doc.getVersion());
  }
Method that detaches all fields contained in the document to the given object

@param self :- The object containing this handler instance

@throws InvocationTargetException
@throws IllegalAccessException
@throws NoSuchMethodException