public <T> T[] toArray(final T[] a) {
   underlying.toArray(a);
   final ODatabasePojoAbstract<TYPE> database = getDatabase();
   for (int i = 0; i < a.length; ++i)
     a[i] = (T) database.getUserObjectByRecord((OIdentifiable) a[i], fetchPlan);
   return a;
 }
  public boolean containsAll(final Collection<?> c) {
    final ODatabasePojoAbstract<TYPE> database = getDatabase();
    for (Object o : c)
      if (!underlying.contains(database.getRecordByUserObject(o, false))) return false;

    return true;
  }
 public boolean removeAll(final Collection<?> c) {
   setDirty();
   boolean modified = false;
   final ODatabasePojoAbstract<TYPE> database = getDatabase();
   for (Object o : c)
     if (!underlying.remove(database.getRecordByUserObject(o, false))) modified = true;
   return modified;
 }
 public boolean addAll(final Collection<? extends TYPE> c) {
   boolean modified = false;
   setDirty();
   final ODatabasePojoAbstract<TYPE> database = getDatabase();
   for (Object o : c)
     if (!underlying.add(database.getRecordByUserObject(o, false))) modified = true;
   return modified;
 }
  protected void convertAll() {
    if (converted || !convertToRecord) return;

    final Set<Object> copy = new HashSet<Object>(this);
    underlying.clear();
    final ODatabasePojoAbstract<TYPE> database = getDatabase();
    for (Object e : copy) {
      if (e != null) {
        if (e instanceof ORID)
          add(
              database.getUserObjectByRecord(
                  (ORecordInternal<?>)
                      ((ODatabaseRecord) getDatabase().getUnderlying()).load((ORID) e, fetchPlan),
                  fetchPlan));
        else if (e instanceof ODocument)
          add(database.getUserObjectByRecord((ORecordInternal<?>) e, fetchPlan));
        else add(e);
      }
    }

    converted = true;
  }