public virtual NeoDatis.Odb.OID SaveBTree(NeoDatis.Btree.IBTree treeToSave)
 {
     nbSaveTree++;
     try
     {
         NeoDatis.Odb.OID oid = (NeoDatis.Odb.OID)treeToSave.GetId();
         if (oid == null)
         {
             // first get the oid. -2 : it could be any value
             oid = engine.GetObjectWriter().GetIdManager().GetNextObjectId(-2);
             treeToSave.SetId(oid);
             oid = engine.Store(oid, treeToSave);
             if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
             {
                 NeoDatis.Tool.DLogger.Debug("Saved btree " + treeToSave.GetId() + " with id " + oid
                                             + " and  root " + treeToSave.GetRoot());
             }
             if (this.tree == null)
             {
                 this.tree = treeToSave;
             }
             oids.Add(oid, treeToSave);
         }
         else
         {
             oids.Add(oid, treeToSave);
             AddModifiedOid(oid);
         }
         return(oid);
     }
     catch (System.Exception e)
     {
         throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Btree.BTreeError.InternalError
                                                    , e);
     }
 }