docs: private Object getDBObject(Identity oid) throws ClassNotPersistenceCapableException
      {
          Class c = oid.getObjectsRealClass();
  
          if (c == null)
          {
              logger.info("Real class for used Identity object is 'null', use top-level class instead");
              c = oid.getObjectsTopLevelClass();
          }
  
          ClassDescriptor cld = getClassDescriptor(c);
          Object newObj = getPlainDBObject(cld, oid);
  
          // loading references is useful only when the Object could be found in db:
          if (newObj != null)
          {
              if (oid.getObjectsRealClass() == null)
              {
                  oid.setObjectsRealClass(newObj.getClass());
              }
  
              /*
               * synchronize on newObj so the ODMG-layer can take a snapshot only of
               * fully cached (i.e. with all references + collections) objects
               */
              synchronized (newObj)
              {
                  objectCache.enableMaterializationCache();
                  try
                  {
                      // cache object immediately , so that references
                      // can be established from referenced Objects back to this Object
                      objectCache.doInternalCache(oid, newObj, ObjectCacheInternal.TYPE_NEW_MATERIALIZED);
  
                      /*
                       * Chris Lewington: can cause problems with multiple objects
                       * mapped to one table, as follows:
                       *
                       * if the class searched on does not match the retrieved
                       * class, eg a search on an OID retrieves a row but it could
                       * be a different class (OJB gets all column values),
                       * then trying to resolve references will fail as the object
                       * will not match the Class Descriptor.
                       *
                       * To be safe, get the descriptor of the retrieved object
                       * BEFORE resolving refs
                       */
                      ClassDescriptor newObjCld = getClassDescriptor(newObj.getClass());
                      // don't force loading of references:
                      final boolean unforced = false;
  
                      // 2. retrieve non-skalar fields that contain objects retrievable from other tables
                      referencesBroker.retrieveReferences(newObj, newObjCld, unforced);
                      // 3. retrieve collection fields from foreign-key related tables:
                      referencesBroker.retrieveCollections(newObj, newObjCld, unforced);
                      objectCache.disableMaterializationCache();
                  }
                  catch(RuntimeException e)
                  {
                      objectCache.doLocalClear();
                      throw e;
                  }
              }
          }
  
          return newObj;
      }