/// <param name="oid"> The Oid of the object to be inserted </param>
        /// <param name="nnoi"> The object meta representation The object to be inserted in the database </param>
        /// <param name="isNewObject"> To indicate if object is new </param>
        /// <returns> The position of the inserted object </returns>
        public OID InsertNonNativeObject(OID oid, NonNativeObjectInfo nnoi, bool isNewObject)
        {
            var ci      = nnoi.GetClassInfo();
            var @object = nnoi.GetObject();
            // First check if object is already being inserted
            // This method returns -1 if object is not being inserted
            var cachedOid = _session.GetCache().IdOfInsertingObject(@object);

            if (cachedOid != null)
            {
                return(cachedOid);
            }
            // Then checks if the class of this object already exist in the
            // meta model
            ci = _objectWriter.AddClass(ci, true);
            // Resets the ClassInfo in the objectInfo to be sure it contains all
            // updated class info data
            nnoi.SetClassInfo(ci);
            // Mark this object as being inserted. To manage cyclic relations
            // The oid may be equal to -1
            // Later in the process the cache will be updated with the right oid
            _session.GetCache().StartInsertingObjectWithOid(@object, oid);
            // false : do not write data in transaction. Data are always written
            // directly to disk. Pointers are written in transaction
            var newOid = WriteNonNativeObjectInfo(oid, nnoi, -1, false, isNewObject);

            if (!Equals(newOid, StorageEngineConstant.NullObjectId))
            {
                _session.GetCache().AddObject(newOid, @object, nnoi.GetHeader());
            }

            return(newOid);
        }